- 消费端不使用注解方式,直接使用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".
- 消费端依然使用注解@Reference
在springboot启动类中加入该注解开启包扫描 @EnableDubbo(scanBasePackages = "com.liu.provider.service") 是用@Reference注解报空指针就是因为没有使用@EnableDubbo注解扫描
springboot整合dubbo时,消费者使用@Reference报空指针问题解决方案
最新推荐文章于 2023-07-22 07:25:52 发布