SpringBoot 报错 A bean with that name has already been defined in class 解决
Posted Adorable_Rocy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SpringBoot 报错 A bean with that name has already been defined in class 解决相关的知识,希望对你有一定的参考价值。
很明显的重名错误,解决方式有两种:1.取别名;2.添加配置
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'hiddenHttpMethodFilter', defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [com/example/test/config/WebMvcConfig.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
在配置文件中添加:即可
spring:
main:
allow-bean-definition-overriding: true
完美解决
以上是关于SpringBoot 报错 A bean with that name has already been defined in class 解决的主要内容,如果未能解决你的问题,请参考以下文章
springboot启动报错:Error creating bean with name 'servletEndpointRegistrar' defined in class pat
springboot启动报错:Error creating bean with name 'servletEndpointRegistrar' defined in class pat
springboot启动报错 error creating bean with name ‘defaultvalidator‘ defined in class path resource
springboot Error creating bean with name "XXX" Unsatisfied dependency expressed through fi
Spring Boot报错:Error creating bean with name 'sqlSessionFactory' ...
The bean 'dataSource',could not be registered.A bean with that name has already been defined