You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/20 04:30:50 UTC

[GitHub] [dubbo] changfubai edited a comment on issue #829: spring 配置文件中 配置default-lazy-init="true" 时 dubbo扫描不起作用??

changfubai edited a comment on issue #829:
URL: https://github.com/apache/dubbo/issues/829#issuecomment-922628738


   > For this issue, there are two aspects we need to consider as follows
   > 
   > * **XML configuration supports lazy initialization or not**
   >   For XML configuration, we need to consider `default-lazy-init` in `beans` and `lazy-init` in the specified `bean`,  see them as below:
   >   ```java
   >   <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   >          xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
   >          xmlns="http://www.springframework.org/schema/beans"
   >          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
   >       http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd" default-lazy-init="true"> // default-lazy-init
   >   
   >       <dubbo:application name="application"/>
   >   
   >       <!-- service configuration -->
   >       <dubbo:service interface="org.apache.dubbo.config.spring.api.DemoService" ref="demoService"/>
   >   		// lazy-init for the specified bean
   >       <bean id="demoService" class="org.apache.dubbo.config.spring.impl.DemoServiceImpl" lazy-init="true"/>
   >   
   >   </beans>
   >   ```
   >   
   >   
   >       
   >         
   >       
   >   
   >         
   >       
   >   
   >       
   >     
   >   If the `bean` is referenced by `dubbo:service` , which cannot be lazy initialized no matter `default-lazy-init` or `lazy-init` sets `true`, because `dubbo:service` don't support lazy initialization.
   >   `DubboBeanDefinitionParser` will parse all beans like `dubbo:xxx`. There seems to be no problem here, if all of them don't support lazy initialization(there are no `lazy-init` attribute).
   >   ```java
   >   RootBeanDefinition beanDefinition = new RootBeanDefinition();
   >   beanDefinition.setBeanClass(beanClass);
   >   beanDefinition.setLazyInit(false); // There is no problem here, beause all of dubbo:xxx bean don't support lazy-init attribute
   >   ```
   > 
   > We can dissucss if all of `dubbo:xxx ` beans need to support `lazy-init` attribute
   > 
   > * **Annotation configuration supports lazy initialization or not**
   >   I have tested that Lazy annotation don't support and I have fix this issue. see [fix: Support Lazy annotation #7981](https://github.com/apache/dubbo/pull/7981)
   
   @pinxiong 
   大佬您好,我在您提完#7981 后,发现如果在privoder实现类上加上@Lazy时,provider就不会暴露到注册中心去了#8770,
   按您这里的描述,provider应该是不支持@Lazy的,只是consumer侧支持对吧?
   目前看应该是下图中把provider加上了@Lazy,导致provider延迟加载,没有触发ServiceConfig的export方法,从而没有注册到注册中心去。
   ![image](https://user-images.githubusercontent.com/20989201/133956805-b9671cd0-f053-469f-a81c-c4c8618f499c.png)
   
   目前我的改法是,去掉service的@Lazy标记。
   您看我的理解是对的么?  


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org