从spring官网下载的Eureka client demo项目,在本地环境运行后报错如下:
Failed to initialize DiscoveryClient!
Error creating bean with name 'scopedTarget.eurekaClient' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.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!
我是用maven工具来管理项目依赖的,问题应该是出在pom.xml文件里了。
只需添加如下依赖即可:
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-apache-client4</artifactId>
<version>1.19.4</version>
</dependency>
参考:
更多疑问,请添加微信探讨交流~~