springboot版本:2.0.2.RELEASE,springcloud版本:Finchley.RC2
在使用Feign消费服务者时,首先引入feign的jar包
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-feign</artifactId> </dependency>
然后在入口类中加入注解@EnableFeignClients,但是却引不进来
后来引入
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-openfeign-core</artifactId> <version>2.0.0.RC2</version> </dependency>
注解成功引入,但是启动报错:
2018-06-20 19:33:53.799 ERROR 20984 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field productClient in com.zsl.order.controller.OrderController required a bean of type 'org.springframework.cloud.openfeign.FeignContext' that could not be found.
- Bean method 'feignContext' not loaded because @ConditionalOnClass did not find required class 'feign.Feign'
Action:
Consider revisiting the conditions above or defining a bean of type 'org.springframework.cloud.openfeign.FeignContext' in your configuration.
报错原因:jar包引入错误
解决方法:
将openfeign的jar包换为
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> <version>2.0.0.RC1</version> </dependency>问题解决