spring cloud Eureka Client feign启动报错

其实开始就想到是版本的问题,各种试各种搜,还是启动会报错,折腾了两天,最后终于解决了。。

我用的gradle

开始版本是 springBootVersion = '2.0.0.M3'  springCloudVersion = 'Finchley.M2'

依赖是// Eureka Client
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')

// Feign

compile('org.springframework.cloud:spring-cloud-starter-openfeign')

启动之后一直提示找不到类,后来到这个jar包下看,确实没有这个类啊,于是想到可能是spring boot 和 cloud版本不匹配

Caused by: java.lang.NoClassDefFoundError: org/springframework/cloud/client/loadbalancer/LoadBalancedRetryFactory
     at java.lang.Class.getDeclaredMethods0(Native Method) ~[na: 1.8 .0_161]
     at java.lang.Class.privateGetDeclaredMethods(Class.java: 2701 ) ~[na: 1.8 .0_161]
     at java.lang.Class.getDeclaredMethods(Class.java: 1975 ) ~[na: 1.8 .0_161]
     at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java: 641 ) ~[spring-core- 5.0 . 0 .RC3.jar: 5.0 . 0 .RC3]
     ...  19  common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory
     at java.net.URLClassLoader.findClass(URLClassLoader.java: 381 ) ~[na: 1.8 .0_161]
     at java.lang.ClassLoader.loadClass(ClassLoader.java: 424 ) ~[na: 1.8 .0_161]
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java: 338 ) ~[na: 1.8 .0_161]
     at java.lang.ClassLoader.loadClass(ClassLoader.java: 357 ) ~[na: 1.8 .0_161]
     ...  23  common frames omitted

后来改成最新版本springBootVersion = '2.0.1.RELEASE'  springCloudVersion = 'Finchley.M9' 

可以说看起来基本不报错了控制台打印了一大堆,接近成功,但是最后还是报错,匪夷所思啊,各种搜索,github也很多人提到这个错,有人还说是bug这那的。我开始也以为哪里配错了?问题端口设置不一样啊。

org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)

最后发现,添加如下这个依赖之后问题奇迹般的解决了。。完美启动,http://localhost:8761/能检测到,feign也可以访问。

compile('org.springframework.boot:spring-boot-starter-web')

上午其实在一个博客看到了说添加starter-web依赖,但是下面又有人说这个方法不好用于是就没试。。具体为什么这样我还没研究,但是问题解决了是真的.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值