java.lang.ClassNotFoundException:com.netflix.discovery.EurekaClientConfig [英] java.lang.ClassNotFoundException: com.netflix.discovery.EurekaClientConfig
问题描述
我正在使用Spring Cloud Eureka,并使用 Spring Initializr ( http://start.spring.io/).使用 Spring Boot 2.0.2.RELEASE 生成的POM用户 Eureka Finchley.RC2 .当我在主类中添加注释 @EnableEurekaServer
时,也使用 @SpringBootApplication
进行注释,然后使用以下命令启动服务器:
I'm using Spring Cloud Eureka and creating the project using Spring Initializr (http://start.spring.io/). The generated POM user Eureka Finchley.RC2 with Spring Boot 2.0.2.RELEASE. When I add the annotation @EnableEurekaServer
in the main class, the one annotated with @SpringBootApplication
also, and I start the server with following command:
mvn spring-boot:run
我收到例外
java.lang.ClassNotFoundException: com.netflix.discovery.EurekaClientConfig
以下是Initializr生成的pom.xml:
the following is the pom.xml generated by the Initializr:
<?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>it.javaboss</groupId>
<artifactId>api-gateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>api-gateway</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.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>
<spring-cloud.version>Finchley.RC2</spring-cloud.version>
</properties>
<dependencies>
<!-- <dependency> -->
<!-- <groupId>org.springframework.cloud</groupId> -->
<!-- <artifactId>spring-cloud-starter-config</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</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/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
推荐答案
正如"rosa lu"所说,启动尤里卡服务器时,我遇到以下类似问题:java.lang.NoClassDefFoundError:com/netflix/discovery/converters/XmlXStream SpringBoot = 2.0.5.RELEASE
SpringCloud.version = Finchley.SR1
正如"rosa lu"所说,我将本地maven存储库更改为新路径,然后重建项目,然后解决问题
我希望我的回答可以对遇到同样问题的任何人有所帮助.
As 'rosa lu' said, when launch eureka server I have the similar issue as below:
java.lang.NoClassDefFoundError:com/netflix/discovery/converters/XmlXStream
SpringBoot=2.0.5.RELEASE
SpringCloud.version=Finchley.SR1
As 'rosa lu' said, I change my local maven repository to a new path, and rebuild my project, then solve the problem
I hope my answer can help anyone who has the same issue .
这篇关于java.lang.ClassNotFoundException:com.netflix.discovery.EurekaClientConfig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!