ApplicationConfig 提前加载导致的 org.apache.dubbo.config.ApplicationConfig#0: defined in null

n53p2ov0  于 4个月前  发布在  Apache
关注(0)|答案(2)|浏览(152)

求问题验证解决思路

现象所在 version:2.7.15

在2.7.3中使用如下方法注入bean是可以成功的

@Configuration
@RequiredArgsConstructor
@EnableConfigurationProperties({A.class, B.class})
public class DubboBaseAutoConfig implements InitializingBean{
    @Bean
    @Primary
    @ConditionalOnMissingBean(ApplicationConfig.class)
    public ApplicationConfig applicationConfig()

然而在2.7.15中会出现这样的错误

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

Description:

Parameter 3 of constructor in com.demo.web.impl.ServiceImpl required a single bean, but 2 were found:
	- applicationConfig: defined by method 'applicationConfig' in class path resource [com/demo/starter/dubbo/support/DubboBaseAutoConfig.class]
	- org.apache.dubbo.config.ApplicationConfig#0: defined in null

怀疑是提前实例化导致在

org.springframework.context.support.AbstractApplicationContext#finishBeanFactoryInitialization

实例化的时候,存在两个 org.apache.dubbo.config.ApplicationConfig#0 导致的问题

想找个方法验证猜想并解决问题,却没有什么头绪。

相关问题