错误描述
Description:
Field FeignClient in xx required a bean of type 'org.springframework.cloud.openfeign.FeignContext' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'org.springframework.cloud.openfeign.FeignContext' in your configuration.
原因
版本冲突。之前SpringBoot版本用的2.5.3没这个问题,升级到3.0.1之后报错[1]
因为Spring Boot 3.0.0 中的Spring.factories被移除,所以之前的版本配置失败了。
解决
在启动类之前加上
@ImportAutoConfiguration({FeignAutoConfiguration.class})
尝试再次启动报错

可能因为Feign的自动配置需要db依赖,我直接在pom中加上
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
之后顺利启动

博客主要讲述Spring Boot从2.5.3升级到3.0.1后出现报错的问题。原因是Spring Boot 3.0.0移除了Spring.factories,导致之前版本配置失败。解决时先在启动类前添加内容仍报错,后发现可能因Feign自动配置需db依赖,在pom中添加后顺利启动。

3504

被折叠的 条评论
为什么被折叠?



