apache / dubbo-spring-boot-project

Spring Boot Project for Apache Dubbo
https://dubbo.apache.org
Apache License 2.0
5.41k stars 1.88k forks source link

@Reference 引用的服务注入为空 #306

Closed YukunChow closed 5 years ago

YukunChow commented 5 years ago

application.ymal

dubbo:
  registries:
    - id: master
      address: zookeeper://127.0.0.1:2181
      isDefault: true
    - id: user-center-zk
      address: zookeeper://10.173.153.112:2181
  application:
    id: insurance-web
    name: insurance-web
server:
  port: 8085

Component

    @Reference(registry = Constant.USER_CENTER_ZK_ID)
    private RegistService registService;

启动类,注解试了DubboComponentScan、EnableDubboConfig,都不行,把包名写上也不行

@EnableDubbo
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class WebApplication {

    public static void main(String[] args) {
        new SpringApplicationBuilder(WebApplication.class)
                .run(args);
    }

}

SpringBoot 版本2.1.0.RELEASE、Java11、dubbo-spring-boot-starter版本0.2.0

wangmingbo123 commented 5 years ago

有异常信息吗

YukunChow commented 5 years ago

有异常信息吗 注入对象为空

wangmingbo123 commented 5 years ago

上传个完整的demo例子看哈

YukunChow commented 5 years ago

目前猜测可能是因为Spring或者JDK版本太高,配置是没错的,之前在低版本项目都是可以的。算了这项目换SpringCloud吧还是。

wangmingbo123 commented 5 years ago

我本地测试了下 好像没有遇到你的问题,不太清楚你是怎么配置的

mercyblitz commented 5 years ago

Please update Dubbo 2.6.5

paytham commented 5 years ago

@TuringHero 换成properties的配置文件,读取yaml的bug我认为还没修复,我也是同样的问题,换成properties就没出现了

mercyblitz commented 5 years ago

Please add Dubbo 2.6.5 in order to override indirectly dependencies:

<dependency>
    <groupId>com.alibaba.boot</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>0.2.0</version>
</dependency>

<!-- Dubbo -->
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>dubbo</artifactId>
    <version>2.6.5</version>
</dependency>
<!-- Spring Context Extras -->
<dependency>
    <groupId>com.alibaba.spring</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>1.0.2</version>
</dependency>

There was an issue about YAML format support in legacy Dubbo.