kylixs edited a comment on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-877050506


   > ```
   > @DubboReference(timeout = 50000)
   > private RoleAuthorizationService roleAuthorizationService;
   > ```
   > 
   > 这种方式同一个api引用多了很容易出错,对开发来说很不友好
   
   在Dubbo3中推荐单独的配置类定义DubboReference注解,其他地方使用Spring `@Autowired ` InterfaceType 
来注入。
   
   在Dubbo2中DubboReference注解的作用是创建Reference proxy并且注入目标的field/setter方法。
   
在Dubbo3中,上述功能仍然保留,只是加强了配置检查,避免出现相同三元组(group,interface,version)不同属性的情况。当出现这种情况时,如果按照第一个扫描到的注解来生成reference对象,后面解析到的相同三元组的DubboReference注解配置被忽略,这种行为是带不确定性的,有可能应用刚好是可以正常运行,也有可能是非期望的配置参数。
   
   
此类问题的根本原因是Dubbo2对DubboReference注解处理是不严谨的,不能为了兼容Dubbo2而增加一些不必要的功能,应该尽量按照最佳实践去编写代码。


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to