You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "yuxiao97 (GitHub)" <gi...@apache.org> on 2019/03/27 07:05:37 UTC

[GitHub] [incubator-dubbo] yuxiao97 opened issue #3749: Why or @Reference cannot exist as a Spring Bean to avoid @Autowired errors in the IDEA?

- [ ] I have searched the [issues](https://github.com/apache/incubator-dubbo/issues) of this repository and believe that this is not a duplicate.
- [ ] I have checked the [FAQ](https://github.com/apache/incubator-dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.

### Environment

* Dubbo version: 2.6.0
* Operating System version: windows 10
* Java version: 1.8

### Steps to reproduce this issue
1:Config <dubbo:refrence>;
2:@Autowired <dubbo:refrence> Service in Service

### Expected Result

I hope this way above can avoid IDEA errors about can not found xxx Beans.




[ 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

[GitHub] [incubator-dubbo] mercyblitz commented on issue #3749: Why or @Reference cannot exist as a Spring Bean to avoid @Autowired errors in the IDEA?

Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
> > 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;
}
```



[ 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


[GitHub] [incubator-dubbo] yuxiao97 commented on issue #3749: Why or @Reference cannot exist as a Spring Bean to avoid @Autowired errors in the IDEA?

Posted by "yuxiao97 (GitHub)" <gi...@apache.org>.
> 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.

[ 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


[GitHub] [incubator-dubbo] yuxiao97 commented on issue #3749: Why or @Reference cannot exist as a Spring Bean to avoid @Autowired errors in the IDEA?

Posted by "yuxiao97 (GitHub)" <gi...@apache.org>.
> > > 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


[GitHub] [incubator-dubbo] mercyblitz commented on issue #3749: Why or @Reference cannot exist as a Spring Bean to avoid @Autowired errors in the IDEA?

Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
Because of `@Reference` supports 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.

[ 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


[GitHub] [incubator-dubbo] mercyblitz commented on issue #3749: Why or @Reference cannot exist as a Spring Bean to avoid @Autowired errors in the IDEA?

Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
> > 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;
}
```



[ 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


[GitHub] [incubator-dubbo] mercyblitz commented on issue #3749: Why or @Reference cannot exist as a Spring Bean to avoid @Autowired errors in the IDEA?

Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
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.

[ 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


[GitHub] [incubator-dubbo] mercyblitz commented on issue #3749: Why or @Reference cannot exist as a Spring Bean to avoid @Autowired errors in the IDEA?

Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
Because of `@Reference` supports 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.

[ 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