Error creating bean with name 'scopedTarget.eurekaClient' defined in class path

1,696 阅读1分钟

使用eureka注册服务的时候报的错,tmd查了半天可算解决了

那个老哥说他 在引入spring-cloud-starter-netflix-eureka-client和spring-boot-starter-web两个依赖的时候,会出现冲突。由于代码里面,用了Spring MVC的Rest方式,而没有用spring-cloud-starter-netflix-eureka-client本身包含Jesery Rest方式。导致出现下面的BUG。 我也用了restTemplate调用来着,估计是因为这个

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!
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    <version>2.0.2.RELEASE</version>
    <!-- 排除Jersey,用SpringMVC Rest方式-->
    <exclusions>
        <exclusion>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-apache-client4</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- 添加jersey-server依赖 -->
<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-server</artifactId>
    <version>2.25.1</version>
</dependency>