Springboot报"could not be registered. A bean with that name has already been defined and overrid
下文笔者讲述Springboot中修改bean定义的信息,出现以下错误的解决处理
编译Spring boot时,出现以下错误
出现这种问题,主要是Spring默认不能修改bean定义
我们只需在application中进行相应的配置即可
编译Spring boot时,出现以下错误
could not be registered. A bean with that name has already been defined and overriding is disabled

出现这种问题,主要是Spring默认不能修改bean定义
我们只需在application中进行相应的配置即可
方式1:
修改application配置文件
spring.main.allow-bean-definition-overriding: true
方式2:
springboot启动时,设置相应的属性
public static void main(String[] args) {
SpringApplication application = new SpringApplication(new Class<?>[]{ResourceApplication.class});
application.setAllowBeanDefinitionOverriding(true);
application.run(args);
}
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


