dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

Can not find registryConfig when use @Reference injection.

Open horizonzy opened this issue 6 years ago • 4 comments

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.

horizonzy avatar Apr 27 '20 03:04 horizonzy

     applicationConfig.setRegistry(registryConfig());

删掉

CodeIngL avatar Apr 29 '20 07:04 CodeIngL

原本就是这么设计的吗

horizonzy avatar May 01 '20 07:05 horizonzy

不是,只是解决方案而已

CodeIngL avatar May 09 '20 02:05 CodeIngL

嗯。我看最新的版本这块代码已经被重构了,不会有该问题。不会去检测applicationConfig和consumerConfig是否存在了

horizonzy avatar May 09 '20 02:05 horizonzy