【已解决】The bean ‘dubboConfigConfiguration.Single’ could not be registered. A bean with that name has already been defined and overriding is disabled.异常解决
今天的Springboot项目在集成dubbo的时候,报了这么一个异常。
***************************
APPLICATION FAILED TO START
***************************Description:The bean 'dubboConfigConfiguration.Single' 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
如图片所示:
这个其实是dubbo版本的一个问题。
dubbo版本在2.6.5之前是使用 DubboConfigConfigurationSelector 实现ImportSelector 返回类名称去加载的
而在2.6.8之后变了,是使用 DubboConfigConfigurationRegistrar 实现ImportBeanDefinitionRegistrar 使用Spring工具类注册加载的
初步判断DubboConfigConfigurationRegistrar在注册的时候allow-bean-definition-overriding 值为false,循环register的时候抛出异常
DefaultListableBeanFactory 中allowBeanDefinitionOverriding值默认为true 但是在SpringApplication 进行赋值,当没配置此参数时,会被设置成false
所以,手动设置该值即可解决。
properties通过添加:
spring.main.allow-bean-definition-overriding=true
yml通过添加:
main:allow-bean-definition-overriding: true
本文发布于:2024-02-01 07:25:21,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170674352334872.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |