XXL-JOB 如何整合dubbo?

阿裏雲問答 2022-01-07 22:56:59 阅读数:654

xxl-job xxl job 整合 dubbo

XXL-JOB 如何整合dubbo?




采納答案1:

(1)引入dubbo-spring-boot-starter和業務facade jar包依賴。

<dependency> <groupId>com.alibaba.spring.boot</groupId> <artifactId>dubbo-spring-boot-starter</artifactId> <version>2.0.0</version></dependency> <dependency> <groupId>com.demo.service</groupId> <artifactId>xxx-facade</artifactId> <version>1.9-SNAPSHOT</version></dependency>

2)配置文件加入dubbo消費端配置(可根據環境定義多個配置文件,通過profile切換)。

Dubbo 服務消費者配置

spring.dubbo.application.name=xxl-job spring.dubbo.registry.address=zookeeper://zookeeper.xyz:2183spring.dubbo.port=20880 spring.dubbo.version=demospring.dubbo.group=demo-service

(3)代碼中通過@Reference注入facade接口即可。

@Reference(check = false,version = "demo",group="demo-service")private OfflineTaskExecutorFacade offlineTaskExecutorFacade;

(4)啟動程序加入@EnableDubboConfiguration注解。

@[email protected] class XxlJobExecutorApplication { public static void main(String[] args) { SpringApplication.run(XxlJobExecutorApplication.class, args); }}

版权声明:本文为[阿裏雲問答]所创,转载请带上原文链接,感谢。 https://gsmany.com/2022/01/202201072256590649.html