Field discoveryClient in com.demo.eureka_client.controller.DcController required a bean of type 'com

来源:互联网 发布:linux man help 编辑:程序博客网 时间:2024/06/15 13:38

原帖链接:http://www.spring4all.com/article/291点击打开链接

问题描述:

     按照原帖的教程,在编写eureka-client代码后,启动eureka-client发现启动失败

并提示:
Description:
Field discoveryClient in com.demo.eureka_client.controller.DcController required a bean of type'com.netflix.discovery.DiscoveryClient' that could not be found.

Action:
Consider defining a bean of type 'com.netflix.discovery.DiscoveryClient'in your configuration.

仔细检查了代码,在启动类上加上了@EnableDiscoveryClient仍然还有这个错误。

问题原因:DiscoveryClient导错了jar包。
      我导入了com.netflix.discovery.DiscoveryClient;正确的应该是 importorg.springframework.cloud.client.discovery.DiscoveryClient;

解决方案:
      导入正确的jar包即可
     import org.springframework.cloud.client.discovery.DiscoveryClient
阅读全文
0 0