bean重复注入问题
2.3.4.RELEASE版本默认关闭了重复注入自动覆盖开关,所以如果写法不规范在低版本重复注入不报错,但是在高版本就会报错。
解决方法:
- 打开开关,容易引入其他问题,不推荐
spring.main.allow-bean-definition-overriding=true - 根据报错内容,将重复注入的bean进行调整,推荐
ProxyTransactionManagementConfiguration
APPLICATION FAILED TO START
Description:
The bean ‘org.springframework.transaction.config.internalTransactionAdvisor’, defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class], could not be registered. A bean with that name has already been defined and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
这是ProxyTransactionManagementConfiguration.class这个bean在创建时重复了,springboot的自动装配和我的程序同时创建了相同类型的bean。之所以报这个异常是因为在Spring2中增加了防止bean重复覆盖的策略,如果有重复则会直接报出异常,而不是像从前一样默默覆盖,导致你的bean被莫名替换,难以排查问题。
解决方法:@SpringBootApplication(exclude = TransactionAutoConfiguration.class)
在启动类中排除。
**
java.lang.NoClassDefFoundError: com/fasterxml/jackson/datatype/jsr310/ser/ZoneIdSerializer
springboot自身的框架中引入了jackson框架,和pom中直接引入的包冲突
解决方法:
将pom中直接引入的jackson升级到高版本:2.11.2
redis中SafeEncoder类找不到
高版本springboot中针对safeencoder的引用路径改变了
解决方法:
升级redis-client版本到 3.1.0 版本
自定义结尾.do和.action不能使用
解决方法:
设置可用协议spring.mvc.content-negotiation.media-types.do=text/dospring.mvc.content-negotiation.media-types.action=text/action
