Eureka服务启动错误

时间:2018-05-02 14:19:29

标签: spring spring-boot netflix-eureka spring-cloud-netflix

我已经创建了一个spring boot应用程序,用于在名为“eureka-service”的Eureka Service中注册我的应用程序。在运行应用程序时,它会抛出错误。我正在使用启动版本'2.0.1'这里是堆栈跟踪:

java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedDataBinder
  at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.getFirstNonLoopbackHostInfo(HostInfoEnvironmentPostProcessor.java:45)
  at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.postProcessEnvironment(HostInfoEnvironmentPostProcessor.java:34)
  at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:183)
  at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:169)
  at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
  at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
  at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
  at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
  at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:358)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
  at com.rest.EurekaServerApplication.main(EurekaServerApplication.java:12)

Caused by: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedDataBinder
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  ... 15 common frames omitted

下面是我使用过的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.rest</groupId>
<artifactId>Eureka-server</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>

<name>Eureka-server</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka-server</artifactId>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Camden.SR6</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

我尝试寻找答案,但这些选项对我不起作用。

1 个答案:

答案 0 :(得分:0)

不应将Spring Boot 2.x与Spring Cloud Edgware或更早版本(Dalston,Camden,......)混合。

Spring Boot 2.0.x应该与Spring Cloud Finchley一起使用,这还不是GA,它是RC1截至05/02/2018。

https://github.com/spring-projects/spring-cloud/wiki/Spring-Cloud-Finchley-Release-Notes

https://github.com/spring-projects/spring-cloud/wiki/Spring-Cloud-Camden-Release-Notes