alibaba / dubbo-spring-boot-starter

Dubbo Spring Boot Starter
Apache License 2.0
2.1k stars 745 forks source link

@Configuration 的类无法注入 @Reference #62

Closed wcp1231 closed 6 years ago

wcp1231 commented 6 years ago

看了一下逻辑,应该是所有 @Configuration 都会在运行时被换成 CGLib 生成的子类,所以代码里

https://github.com/alibaba/dubbo-spring-boot-starter/blob/master/src/main/java/com/alibaba/dubbo/spring/boot/DubboConsumerAutoConfiguration.java#L77

是拿不到添加了 @Reference 注解的字段的,所以也就不能注入了。

xionghuiCoder commented 6 years ago

hi, consumer使用@Configuration注解bean时,bean同时实现SpringProxy接口即可work.

ps: 如果provider使用@Configuration注解时需要在bean的@Service注解加上interfaceClass配置即可,例如: @Service(interfaceClass = XXX.class)

wcp1231 commented 6 years ago

好的,thx