• xxl-job学习


    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);
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    在这里插入图片描述

    四、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>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28

    5.2、job类的使用

    在这里插入图片描述

    5.3、其他的看gitee地址

  • 相关阅读:
    leetcode面试题之哈希表
    URL字符解码
    【Java】# 256位密钥加密错误,java.security.InvalidKeyException:Illegal key size错误
    elasticsearch源码解析TODO列表
    浅谈电动汽车充电桩设计与应用研究
    HUD—6287,口算训练,思维,素因子分解,lower_bound, upper_bound
    本人开发Android视频编码和直播推流使用到的相关命令
    springboot + solr
    SpringMVC执行原理
    linux查看服务器登录成功和登录失败的命令
  • 原文地址:https://blog.csdn.net/M1275601161/article/details/126279396