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 2018/07/18 09:49:05 UTC

[GitHub] hsl727261250 edited a comment on issue #2093: dubbo注解service与spring注解service同时在一个类上使用, 无法暴露服务

hsl727261250 edited a comment on issue #2093: dubbo注解service与spring注解service同时在一个类上使用, 无法暴露服务
URL: https://github.com/apache/incubator-dubbo/issues/2093#issuecomment-405873603
 
 
   为什么会同时使用dubbo和spring的service注解? 因为这个服务内部外部都要使用.
   
   经过调试发现是lazy-init的原因.
   我的项目指定了全局lazy-init=true, 所以一般情况下spring管理的类都会延迟实例化.
   当我单独使用dubbo的service注解时, 该类不由spring管理, 启动时正常实例化正常暴露服务.
   当同时使用两个注解时, 项目启动时不会实例化该类, 所以无法暴露服务.
   当同时使用两个注解, 并在其他类中Autowired该类时, 启动时就实例化, 正常暴露服务.
   
   解决方法:
   在服务上指定@Lazy(false)注解, 在项目启动时就实例化该类.
   
   有没有办法在同时使用两种注解时, 不引入多余的注解, 让spring在启动时就实例化dubbo类?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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