springcloud版本:Finchley.SR2
springboot版本:2.0.7.RELEASE
1.@EnableFeignClients @FeignClient注解找不到問題
問題原因: finchley版本feign相關(guān)jar包在openfeign包中
解決方案:pom.xml增加相關(guān)依賴
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
2.配置好feign相關(guān)注解后,項目啟動時OpenFeign模塊報錯
異常信息:
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!)
問題原因:openFeign里不包含tomcat的依賴,導致spring容器無法創(chuàng)建一些實例,導致項目無法啟動。
解決方案:pom.xml中增加web依賴
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>