SpringBoot整合XXL-JOB

和其他的定时任务框架比较:

  • 有网页端,可以很方便的修改时间
  • 在线查看日志

本篇文章只讲述如何在开发环境安装XXL-JOB,后续会在 软件安装教程 发布<如何使用Docker安装XXL-JOB>.
参考文档:https://www.jianshu.com/p/fc19b2dfef0e

1.下载XXL-JOB源代码,找到xxl-job-admin,yaml配置相关数据库信息,新建xxl_job数据库,把表结构和数据导入进去
2.修改启动端口
3.找到xxl-job-executor-sample下面的任意一个项目,在xxl-job-executor.properties文件内修改访问xxl-job-admin的路径以及端口

### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
xxl.job.admin.addresses=http://127.0.0.1:9056/xxl-job-admin

### xxl-job, access token
xxl.job.accessToken=

### xxl-job executor appname
xxl.job.executor.appname=xxl-job-executor-sample
### xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null
xxl.job.executor.address=
### xxl-job executor server-info
xxl.job.executor.ip=
xxl.job.executor.port=9998
### 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

4.依次启动两个项目的启动类,然后浏览器访问http://127.0.0.1:9056/xxl-job-admin/,用户名和密码分别是admin,123456
5.找到任务管理,创建任务,执行
6.查看日志,找到调度日志版块的操作按钮,点击执行日志查看即可

注:不能使用log4j来打印日志,需使用这个 XxlJobHelper.log("xxxx");

另外在开发环境(win10)发现一个问题,就是每次调用依次就会生成一个日志文件。暂未找到什么解决方法。

原文地址:https://www.cnblogs.com/lhxBlogs/p/15476849.html