SpringBoot项目集成xxl-job分布式任务调度平台

本文介绍了如何将xxl-job集成到SpringBoot项目中作为分布式任务调度平台。首先,概述了xxl-job的架构和特点,然后详细说明了如何初始化xxl-job,包括数据库脚本执行、调度中心的部署(通过maven打包和后台启动)、客户端配置以及遇到的问题和解决方法。文章还提供了配置文件示例和关键代码片段,帮助读者理解和实施。
摘要由CSDN通过智能技术生成

导向

公司的开发人员说xxl-job写定时任务挺好用、简单的,于是乎去了解了一番,但是学习过程中却也遇到了一些不顺利的事情,以下是这两天所拿下的bug及其前后所部署的操作

了解xxl-job

架构图

在这里插入图片描述

介绍

轻量级分布式任务调度平台
主要基于spring quartz 框架搭建的, 修改了任务调度的模式,采用RPC调用来实现执行器的注册和任务的调度

官方文档及demo

链接: https://www.xuxueli.com/xxl-job/.

初始xxl-job 定时任务框架

在这里插入图片描述
先将上图的数据库脚本在数据库运行即可,如下图:
在这里插入图片描述
然后将我们的xxl-job-admin 模块从整个demo工程拉取下来,如:
在这里插入图片描述
部署调度中心(xxl-job-admin),访问调度中心的管理控制页面:可以直接在idea 中启动程序,也可以将程序打包(maven package),用 “java -jar jar包名称 -d”等后台启动调度中心;
接下来为大家演示:
修改对应的application.properties 文件如下:
修改如图配置即可
在这里插入图片描述
代码也贴上

### web
server.port=8080
server.servlet.context-path=/xxl-job-admin

### actuator
management.server.servlet.context-path=/actuator
management.health.mail.enabled=false

### resources
spring.mvc.servlet.load-on-startup=0
spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:/static/

### freemarker
spring.freemarker.templateLoaderPath=classpath:/templates/
spring.freemarker.suffix=.ftl
spring.freemarker.charset=UTF-8
spring.freemarker.request-context-attribute=request
spring.freemarker.settings.number_format=0.##########

### mybatis
mybatis.mapper-locations=classpath:/mybatis-mapper/*Mapper.xml
#mybatis.type-aliases-package=com.xxl.job.admin.core.model

### xxl-job, datasource
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC 
spring.datasource.username=root
spring.datasource.password=myroot
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

### datasource-pool
spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource      
spring.datasource.tomcat.max-wait=10000
spring.datasource.tomcat.max-active=30
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.validation-query=SELECT 1
spring.datasource.tomcat.validation-interval=30000

### xxl-job, email   修改为你的邮箱名
spring.mail.host=smtp.qq.co
  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值