dubbo
dubbo copied to clipboard
Can not find registryConfig when use @Reference injection.
dubbo-version:2.7.2 When I use @Reference to get reference.And I config ApplicationConfig and RegistryConfig as follow. I config registryConfig in applicationConfig.
@Bean
public ApplicationConfig applicationConfig() {
ApplicationConfig applicationConfig = new ApplicationConfig();
applicationConfig.setName("dubbo-demo-annotation-consumer");
applicationConfig.setRegistry(registryConfig());
return applicationConfig;
}
@Bean
public RegistryConfig registryConfig() {
return new RegistryConfig("zookeeper://127.0.0.1:2181");
}
it will lead referenceBean dosen't init RegistryConfig when afterPropertiesSet(). because referenceBean will check applicaionConfig's registryConfig and consumerConfig's registryConfig is exist.case exist,referenceBean will not init registryConfig. so reference will fail in init() process.
applicationConfig.setRegistry(registryConfig());
删掉
原本就是这么设计的吗
不是,只是解决方案而已
嗯。我看最新的版本这块代码已经被重构了,不会有该问题。不会去检测applicationConfig和consumerConfig是否存在了