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/07/05 07:03:00 UTC

[GitHub] [dubbo] hyberbin opened a new issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

hyberbin opened a new issue #8221:
URL: https://github.com/apache/dubbo/issues/8221


   
   
   ### Environment
   
   * Dubbo version: 3.0.1
   * Operating System version: windows 11
   * Java version: 1.8
   
   ### Steps to reproduce this issue
   
   1.在某个controller中 对roleAuthorizationService引用
       @DubboReference(timeout = 50000)
       private RoleAuthorizationService roleAuthorizationService;
   2. 在另一个controller中 对roleAuthorizationService引用
      @DubboReference
       private RoleAuthorizationService roleAuthorizationService;
   3. 启动报错
   
   
   ### Expected Result
   
   service完全一样,只不过对部分方法有定制,应该能正常启动
   
   ### Actual Result
   
   启动报错
   
   ```
   Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
   14:51:18.522  [main] ERROR o.s.boot.SpringApplication - Application run failed
   org.springframework.beans.factory.BeanCreationException: Already exists another reference bean with the same bean name and type but difference attributes. In order to avoid injection confusion, please modify the name of one of the beans: prev: roleAuthorizationService[ReferenceBean:org.prophetech.hyperone.authorization.service.RoleAuthorizationService(timeout=50000)], new: roleAuthorizationService[ReferenceBean:org.prophetech.hyperone.authorization.service.RoleAuthorizationService()]. Please check private org.prophetech.hyperone.authorization.service.RoleAuthorizationService org.prophetech.hyperone.authorization.controller.UserController.roleAuthorizationService
   	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.registerReferenceBean(ReferenceAnnotationBeanPostProcessor.java:394)
   	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.prepareInjection(ReferenceAnnotationBeanPostProcessor.java:317)
   	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.postProcessBeanFactory(ReferenceAnnotationBeanPostProcessor.java:149)
   	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:291)
   	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:175)
   	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707)
   
   ```
   


-- 
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


[GitHub] [dubbo] kylixs commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
kylixs commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-874522653


   > 觉得还是缺乏便利性,写起来很啰嗦,望兼容
   
   Dubbo 2有不少地方的校验是不严谨的,使用过程可能出现一些奇怪的问题。Dubbo 3中加强了配置检查的严谨性,避免出现混淆含糊的用法。
   
   如果要兼容Dubbo 2的方式,请保证所有相同的reference的@DubboReference注解属性相同,相同的三元组(group, interface, version) 最终只会创建一个reference对象,不会出现上面的错误。
   
   上面的例子使用到RoleAuthorizationService reference的地方可以都修改为:
   ```
   @DubboReference(timeout = 50000)
   private RoleAuthorizationService roleAuthorizationService;
   ```


-- 
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


[GitHub] [dubbo] kylixs commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
kylixs commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-873919884


   > 1.在某个controller中 对roleAuthorizationService引用
   > @DubboReference(timeout = 50000)
   > private RoleAuthorizationService roleAuthorizationService;
   > 2. 在另一个controller中 对roleAuthorizationService引用
   > @DubboReference
   > private RoleAuthorizationService roleAuthorizationService;
   
   这两个地方都是初始化Reference并注入field,但是两个注解的属性不相同,提示相同的beanName但不同的属性的错误,因为无法决定使用哪个注解定义的属性来创建reference对象。
   
   正确的用法是:
   (1) Dubbo 3 之后推荐将reference定义和注入分开, 如可以在一个Java Config类中定义reference,在引用的类中通过`@Autowired`来注入接口代理类。
   定义reference:
   ```
   @Configuration
   class ConsumerConfig {
       @Bean
       @DubboReference(timeout = 50000)
       public ReferenceBean<RoleAuthorizationService> roleAuthorizationService (){
             return new ReferenceBean();
       }
   }
   ```
   或者
   ```
   @Configuration
   class ConsumerConfig {
       @DubboReference(timeout = 50000)
       private RoleAuthorizationService roleAuthorizationService;
   }
   ```
   
   
   注入接口:
   ```
   class FooController {
   
       @Autowired
       private RoleAuthorizationService roleAuthorizationService;
      
      ...
   }
   ```
   
   (2) 兼容Dubbo 2的方式,保证所有相同的reference的@DubboReference注解属性相同,那么最终只会创建一个reference对象,不会出现上面的错误。
   上面的例子应该都修改为: 
   > @DubboReference(timeout = 50000)
   > private RoleAuthorizationService roleAuthorizationService;


-- 
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


[GitHub] [dubbo] kylixs edited a comment on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
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中,上述功能仍然保留,只是加强了配置检查,避免出现相同三元组不同属性的情况。当出现这种情况时,如果按照第一个扫描到的注解来生成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: 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


[GitHub] [dubbo] kylixs edited a comment on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
kylixs edited a comment on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-877074984


   > 建议添加这样的注解:优雅又通用,全部再定义一遍然后用@Autowired,显得啰嗦,又不好与本地service引用区分。
   > 
   > ```
   > public interface FooService {
   >     @RpcConfig(timeout = 50000)
   >      void methodA();
   > 
   >      void methodB();
   > }
   > ```
   
   在接口上定义reference参数一来会对接口造成污染,二来缺乏灵活性,也不能满足多reference实例的需求。
   实践表明,在不同的场景下可能需要动态调整reference参数,通过外部配置来修改reference参数更加灵活实用。
   
   不同的用户习惯不同,一部分Dubbo的老用户习惯xml的配置方式,在统一的类中定义reference注解,在其它地方用Spring `@Autowired`注入,也很好兼容xml配置时的业务代码。


-- 
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


[GitHub] [dubbo] hyberbin commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
hyberbin commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-876046405


   那能不能直接在接口类或方法上加一个注解,其他地方引用的时候直接按原来的方式引入就可以呢?


-- 
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


[GitHub] [dubbo] hyberbin commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
hyberbin commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-877064971


   如果是这样建议去掉timeout 等非三元组属性注解,不然我一个Service接口不可能只在一个地方有引用,一旦引用的地方多了,后期维护将发生灾难,我要调整其中的一个引用还得把其他引用都找出来改一遍。
   建议添加这样的注解:优雅又通用,全部再定义一遍然后用@Autowired,显得啰嗦,又不好与本地service引用区分。
   ```
   public interface FooService {
       @RpcConfig(timeout = 50000)
        void methodA();
   
        void methodB();
   }
   ```


-- 
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


[GitHub] [dubbo] kylixs edited a comment on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
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: 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


[GitHub] [dubbo] hyberbin commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
hyberbin commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-874505610


   觉得还是缺乏便利性,写起来很啰嗦,望兼容


-- 
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


[GitHub] [dubbo] kylixs commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
kylixs commented 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中,上述功能仍然保留,只是加强了配置检查,避免出现相同三元组不同属性的情况。当出现这种情况时,如果按照第一个扫描到的注解来生成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: 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


[GitHub] [dubbo] ouyangnengda commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
ouyangnengda commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-876138234


   > ```
   > @DubboReference(timeout = 50000)
   > private RoleAuthorizationService roleAuthorizationService;
   > ```
   > 
   > 这种方式同一个api引用多了很容易出错,对开发来说很不友好
   
   确实,照这样说 Dubbo3 比 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: 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


[GitHub] [dubbo] kylixs edited a comment on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
kylixs edited a comment on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-873919884


   > 1.在某个controller中 对roleAuthorizationService引用
   > @DubboReference(timeout = 50000)
   > private RoleAuthorizationService roleAuthorizationService;
   > 2. 在另一个controller中 对roleAuthorizationService引用
   > @DubboReference
   > private RoleAuthorizationService roleAuthorizationService;
   
   这两个地方都是初始化Reference并注入field,但是两个注解的属性不相同,提示相同的beanName但不同的属性的错误,因为无法决定使用哪个注解定义的属性来创建reference对象。
   
   正确的用法是:
   (1) Dubbo 3 之后推荐将reference定义和注入分开, 如可以在一个Java Config类中定义reference,在引用的类中通过`@Autowired`来注入接口代理类。
   定义reference:
   ```
   @Configuration
   class ConsumerConfig {
       @Bean
       @DubboReference(timeout = 50000)
       public ReferenceBean<RoleAuthorizationService> roleAuthorizationService (){
             return new ReferenceBean();
       }
   }
   ```
   或者
   ```
   @Configuration
   class ConsumerConfig {
       @DubboReference(timeout = 50000)
       private RoleAuthorizationService roleAuthorizationService;
   }
   ```
   
   
   注入接口:
   ```
   class FooController {
   
       @Autowired
       private RoleAuthorizationService roleAuthorizationService;
      
      ...
   }
   ```
   
   (2) 兼容Dubbo 2的方式,保证所有相同的reference的@DubboReference注解属性相同,那么最终只会创建一个reference对象,不会出现上面的错误。
   上面的例子应该都修改为: 
   ```
   class FooController {
       ...
       @DubboReference(timeout = 50000)
       private RoleAuthorizationService roleAuthorizationService;
       ...
   }
   ```
   ```
   class BarController {
       ...
       @DubboReference(timeout = 50000)
       private RoleAuthorizationService roleAuthorizationService;
       ...
   }
   ```
   
   


-- 
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


[GitHub] [dubbo] kylixs commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
kylixs commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-873919884






-- 
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


[GitHub] [dubbo] hyberbin commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
hyberbin commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-876056678


   ```
   @DubboReference(timeout = 50000)
   private RoleAuthorizationService roleAuthorizationService;
   ```
   这种方式同一个api引用多了很容易出错,对开发来说很不友好


-- 
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


[GitHub] [dubbo] hyberbin commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
hyberbin commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-874505610


   觉得还是缺乏便利性,写起来很啰嗦,望兼容


-- 
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


[GitHub] [dubbo] kylixs edited a comment on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
kylixs edited a comment on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-873919884


   > 1.在某个controller中 对roleAuthorizationService引用
   > @DubboReference(timeout = 50000)
   > private RoleAuthorizationService roleAuthorizationService;
   > 2. 在另一个controller中 对roleAuthorizationService引用
   > @DubboReference
   > private RoleAuthorizationService roleAuthorizationService;
   
   这两个地方都是初始化Reference并注入field,但是两个注解的属性不相同,提示相同的beanName但不同的属性的错误,因为无法决定使用哪个注解定义的属性来创建reference对象。
   
   正确的用法是:
   (1) Dubbo 3 之后推荐将reference定义和注入分开, 如可以在一个Java Config类中定义reference,在引用的类中通过`@Autowired`来注入接口代理类。
   定义reference:
   ```
   @Configuration
   class ConsumerConfig {
       @Bean
       @DubboReference(timeout = 50000)
       public ReferenceBean<RoleAuthorizationService> roleAuthorizationService (){
             return new ReferenceBean();
       }
   }
   ```
   或者
   ```
   @Configuration
   class ConsumerConfig {
       @DubboReference(timeout = 50000)
       private RoleAuthorizationService roleAuthorizationService;
   }
   ```
   
   
   注入接口:
   ```
   class FooController {
   
       @Autowired
       private RoleAuthorizationService roleAuthorizationService;
      
      ...
   }
   ```
   
   (2) 兼容Dubbo 2的方式,保证所有相同的reference的@DubboReference注解属性相同,那么最终只会创建一个reference对象,不会出现上面的错误。
   上面的例子应该都修改为: 
   ```
   class FooController {
       ...
       @DubboReference(timeout = 50000)
       private RoleAuthorizationService roleAuthorizationService;
       ...
   }
   ```
   ```
   class BarController {
       ...
       @DubboReference(timeout = 50000)
       private RoleAuthorizationService roleAuthorizationService;
       ...
   }
   ```
   
   


-- 
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


[GitHub] [dubbo] kylixs commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
kylixs commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-877069464


   > 如果是这样建议去掉timeout 等非三元组属性注解,不然我一个Service接口不可能只在一个地方有引用,一旦引用的地方多了,后期维护将发生灾难,我要调整其中的一个引用还得把其他引用都找出来改一遍。
   
   可以通过属性配置来解决你的问题:
   1、在所有引用reference接口的地方仅指定三元组属性(group, interface, version)
   ```java
   @DubboReference
   private RoleAuthorizationService roleAuthorizationService;
   ```
   2、在application.properties或者config-center中指定reference的其它属性
   ```
   dubbo.reference.com.xxx.RoleAuthorizationService.timeout=5000
   dubbo.reference.com.xxx.RoleAuthorizationService.retries=3
   ```


-- 
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


[GitHub] [dubbo] AlbumenJ commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-876900688


   > > ```
   > > @DubboReference(timeout = 50000)
   > > private RoleAuthorizationService roleAuthorizationService;
   > > ```
   > > 
   > > 
   > >     
   > >       
   > >     
   > > 
   > >       
   > >     
   > > 
   > >     
   > >   
   > > 这种方式同一个api引用多了很容易出错,对开发来说很不友好
   > 
   > 确实,照这样说 Dubbo3 比 Dubbo2 对开发者更不友好了,失去了灵活性
   
   这里涉及到几个问题
   1. 如果开发者期望同一个引用对象在多个地方使用,同时又需要特殊配置参数,可以采用 Spring Bean 方式注入,在统一的地方生成 Dubbo 的 Reference
   2. 如果开发者期望多个地方使用的时候参数是不一样的,需要改变服务三元组(接口+版本+分组)信息,以此来唯一确定一个服务,对于框架来说一直以来的设计理念都是以三元组去做唯一定位的,为了规范使用在 Dubbo 3里面开启了强校验,同时依据最佳实践也不应该三元组一样的情况下改变参数去复用,这样很难去进行服务治理
   3. 如果开发这是希望运行时改变一些参数的,可以参考 RpcContext 动态传递参数


-- 
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


[GitHub] [dubbo] kylixs commented on issue #8221: dubbo consumer端对 方法自定义引入引发启动报错

Posted by GitBox <gi...@apache.org>.
kylixs commented on issue #8221:
URL: https://github.com/apache/dubbo/issues/8221#issuecomment-877074984


   > 建议添加这样的注解:优雅又通用,全部再定义一遍然后用@Autowired,显得啰嗦,又不好与本地service引用区分。
   > 
   > ```
   > public interface FooService {
   >     @RpcConfig(timeout = 50000)
   >      void methodA();
   > 
   >      void methodB();
   > }
   > ```
   
   在接口上定义reference参数一来会对接口造成污染,二来缺乏灵活性,也不能满足多reference实例的需求。
   实践表明,在不同的场景下可能需要动态调整reference参数,通过外部配置来修改reference参数更加灵活实用。
   


-- 
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