SPRINGBOOT 集成xxljob
时间: 2023-11-08 12:06:04 浏览: 94
要在Spring Boot中集成xxl-job,需要进行以下步骤:
1. 在pom.xml文件中添加xxl-job的依赖:
```
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>${xxl.job.version}</version>
</dependency>
```
2. 在application.properties文件中配置xxl-job的相关属性:
```
# xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
xxl.job.admin.addresses=http://localhost:8080/xxl-job-admin
# xxl-job executor appname
xxl.job.executor.appname=executor-sample
# xxl-job executor address
xxl.job.executor.address=http://localhost:9999/xxl-job-executor
# xxl-job executor ip
xxl.job.executor.ip=
# xxl-job executor port
xxl.job.executor.port=9999
# xxl-job executor log path
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
# xxl-job executor log retention days
xxl.job.executor.logretentiondays=30
```
3. 创建JobHandler类并实现IJobHandler接口,实现自己的业务逻辑。
4. 在Spring Boot的启动类上添加@EnableXxlJob注解,开启xxl-job的自动配置。
阅读全文