springboot整合dubbo时,消费者使用@Reference报空指针问题解决方案

  1. 消费端不使用注解方式,直接使用xml,下面贴上consumer.xml代码
    <dubbo:application name="111" owner="abc"/>
    <dubbo:registry address="zookeeper://localhost:2181" check="false"/>
    <dubbo:reference id="classesService"
                     interface="com.liu.provider.service.IClassesService"/>                                        然后在springboot启动类中使用
    @ImportResource(locations = "classpath:consumer.xml")注解把classesService这个bean注入到spring容器,最后消费者代码中再使用@Autowired注解注入该bean"classesService".
  2. 消费端依然使用注解@Reference                                                                                                                                                
    在springboot启动类中加入该注解开启包扫描
    @EnableDubbo(scanBasePackages = "com.liu.provider.service")
    是用@Reference注解报空指针就是因为没有使用@EnableDubbo注解扫描                                                                                                        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值