升级sprongboot3.x问题

1.子模块的bean或者第三方依赖的bean无法注入

类似报错如下

***************************
APPLICATION FAILED TO START
***************************

Description:

Field xxxApi in com.xxx.xxxxImpl 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.

这是因为在springboot3.x中spring.factories被弃用了,造成了bean无法自动注入

原有的spring.factories需要改成如下形式,第三方依赖则需要升级版本(升级到弃用了spring.factories的版本)

#该文件中直接写需要自动注入的类即可
org.springframework.boot.autoconfigure.AutoConfiguration.imports

 

2.存在循环依赖问题

spring6.x之后默认禁止循环依赖

实在要用循环依赖就手动在配置文件中配置

spring.main.allow-circular-references = true

 

 

 

 

参考连接:

https://blog.csdn.net/AL_guli/article/details/134753841

https://www.cnblogs.com/joeblackzqq/p/18036871

posted @ 2024-09-03 16:56  wdgde  阅读(228)  评论(0)    收藏  举报