错误描述

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>

之后顺利启动


参考:
[1]Consider defining a bean of type ‘org.springframework.cloud.openfeign.FeignContext’ in your configuration

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐