xxl_job地址:
https://www.xuxueli.com/xxl-job/
gitee地址:
https://gitee.com/liushanshan126/xxl_job_test
基础学习博客地址:
https://blog.csdn.net/xhmico/article/details/122324950
一、启动(查看上面的学习博客)
二、遇到的问题(Specified key was too long; max key length is 767 bytes)
参考博客:
https://blog.csdn.net/xiaozhegaa/article/details/105550594
三、遇到的问题:定时任务执行方法的时候,始终无法将参数带过去。解决:用错的了方法,方法上的参数直接接收,需要使用XxlJobContext.getXxlJobContext().getJobParam()方法
/**
* bear测试
*/
@XxlJob("bearTest")
public void bearTest(String s) throws Exception {
XxlJobHelper.log("XXL-JOB, Hello World.");
String jobParam = XxlJobContext.getXxlJobContext().getJobParam();
System.out.println("bear测试:"+jobParam);
}
四、java的方式使用xxl_job(继承IJobHandleer)
五、整合到springboot中(1:需要xxl_job的maven依赖;2:配置类、application.properties、logback.xml都是扒的xxl_job项目中的,3:还要一个job类就行了)
5.1、 maven依赖
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bear</groupId>
<artifactId>xxl-job-tesst</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
</project>