在尤里卡服务器中添加尤里卡客户端时出错,客户端模块无法启动



我创建了两个spring云模块,一个是eureka服务器,它运行良好,另一个是尤里卡客户端,当我启动它时,出现了错误。

2018-07-25 18:06:21.717 ERROR 15352 --- [           main] o.s.c.n.e.s.EurekaRegistration           : error getting CloudEurekaClient
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'scopedTarget.eurekaClient' defined in class 
path resource [ . 
org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$Ref .    reshableEurekaClientConfiguration.class]: Bean instantiation via 
factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to 
instantiate [com.netflix.discovery.EurekaClient]: Factory method 
'eurekaClient' threw exception; nested exception is 
java.lang.RuntimeException: Failed to initialize DiscoveryClient!

github链接为:此处你能帮我找出错误吗?

在pom.xml中为客户端使用以下依赖项

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.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.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</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>${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>

在application.properties文件中添加此行

eureka.client.enabled=真正的

然后尝试重新部署。

尝试在添加这两个依赖项后运行,希望它能工作。

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-core</artifactId>
</dependency>

最新更新