0

尝试使用Spring Cloud Netflix v1.2.0.Release 来编写Eureka客户端,但面临以下提及的问题。 PFB代码和配置。netflix eureka客户端“eurekaHealthIndicator”问题

EurekaClient.java

import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 
import org.springframework.boot.builder.SpringApplicationBuilder; 
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 
import org.springframework.context.annotation.ComponentScan; 
import org.springframework.context.annotation.Configuration; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RestController; 


    @Configuration 
    @EnableAutoConfiguration 
    @EnableEurekaClient 
    @RestController 
    @ComponentScan(basePackages={"com.west.eas.netflix.config"}) 
    public class EurekaClient { 

     @RequestMapping("/") 
      public String home() { 
      return "Hello World"; 
      } 

      public static void main(String[] args) { 
       new SpringApplicationBuilder(EurekaClient.class).run(args); 
      } 


    } 

application.yml

server: 
    port: 9000 

spring: 
    application: 
    name: eas-eureka-client 

eureka: 
    client: 
    healthcheck: 
     enabled: true 
    serviceUrl: 
     defaultZone: http://localhost:8761/eureka/ 
    instance: 
    preferIpAddress: true 

bootstrap.yml

spring: 
    application: 
    name: eu-client 
    cloud: 
    config: 
     uri: http://localhost:8888 
encrypt: 
    failOnError: false 

客户未能启动与以下错误

“在 org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration $ EurekaHealthIndicatorConfiguration 方法eurekaHealthIndicator的参数0所需类型的豆‘com.netflix.discovery.EurekaClient’那 可能不会被发现。”

下面的截图将有错误堆栈

enter image description here

我甚至尝试设置健康检查能为false application.yml,但它仍然不会工作的更多细节。任何帮助,将不胜感激。

问候

+1

你的依赖是什么? – spencergibb

+1

为什么在应用程序和引导程序中有不同的'spring.application.name'? – spencergibb

回答

0

@spencergibb提到它在添加依赖项时确实出错了,我试过通过http://start.spring.io/来创建一个新项目,它解决了我的问题。

0

的问题似乎是,你命名你的客户EurekaClient,已经有该名称的bean。将这个类重命名为其他东西,它应该可以工作