dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yuxiao97 (GitHub) <git...@apache.org>
Subject [GitHub] [incubator-dubbo] yuxiao97 commented on issue #3749: Why <dubbo:referende> or @Reference cannot exist as a Spring Bean to avoid @Autowired errors in the IDEA?
Date Wed, 03 Apr 2019 14:08:42 GMT
> > > Because of `@Reference` supports the customized behavior for Dubbo Service,
for example:
> > > ```java
> > > @Reference
> > > private UserService userService;
> > > 
> > > @Reference(protocol="dubbo")
> > > private UserService userService;
> > > ```
> > > 
> > > 
> > > If the above two fields will be enhanced as the Spring Beans, the problem is
how to identify them.
> > 
> > 
> > OK, I know you means, if as the Spring Bean, Spring can not found and initialize
them.
> 
> Thus, Dubbo will provide a new mechanism that `@Reference` enhances a Spring Bean whose
name will be associated with `name()` attribute, and the Client `@Autowired` that bean, for
example:
> 
> ```java
> @Configuration
> public class SomeConfiguration {
>     @Reference(name="userService")
>     private UserService userService;
> 
>     @Reference(name="userService2", protocol="dubbo")
>     private UserService userService2;
>     ...
> }
> ```
> 
> ```java
> @RestController
> public Class UserController {
>    @Autowired
>    @Qualifier("userService")
>    private UserService userService;
> 
>    @Autowired
>    @Qualifier("userService2")
>    private UserService userService2;
> }
> ```

Thanks, expected the function realization!

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3749 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


Mime
View raw message