服务注册和发现Eureka Server启动问题

时间:2018-03-22 19:30:38

标签: spring spring-boot netflix-eureka

我在尝试启动eureka服务器时遇到以下错误.apache commons config lib显示在项目的maven lib部分中。 尝试使用以下URL中给出的相同pom文件 https://spring.io/guides/gs/service-registration-and-discovery/

java.lang.NoClassDefFoundError: org/apache/commons/configuration/Configuration
at org.springframework.cloud.netflix.eureka.server.EurekaServerBootstrap.initEurekaEnvironment(EurekaServerBootstrap.java:111) ~[spring-cloud-netflix-eureka-server-2.0.0.M7.jar:2.0.0.M7]
at org.springframework.cloud.netflix.eureka.server.EurekaServerBootstrap.contextInitialized(EurekaServerBootstrap.java:82) ~[spring-cloud-netflix-eureka-server-2.0.0.M7.jar:2.0.0.M7]
at org.springframework.cloud.netflix.eureka.server.EurekaServerInitializerConfiguration$1.run(EurekaServerInitializerConfiguration.java:71) [spring-cloud-netflix-eureka-server-2.0.0.M7.jar:2.0.0.M7]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
Caused by: java.lang.ClassNotFoundException: org.apache.commons.configuration.Configuration

我正在附加我正在使用的pom.xml

<groupId>com.example</groupId>
<artifactId>eureka-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

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

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

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

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

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Finchley.M8</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>

<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/libs-milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

1 个答案:

答案 0 :(得分:0)

这很可能是由于apache commons-configuration缺失或不兼容的传递依赖。

  • 我建议您使用mvn:dependency tree分析依赖关系树,并确定commons-configuration版本。

  • 您可能希望显式添加最新的maven 你朋友的commoins-configuration

<dependency>
    <groupId>commons-configuration</groupId>
    <artifactId>commons-configuration</artifactId>
    <version>1.9</version>
</dependency>