XXL-JOB执行器配置

XXL-JOB

执行器配置简单来说就是在SpringBoot项目中配置XXL-JOB。

# 1、引入依赖

<dependency>
    <groupId>com.xuxueli</groupId>
    <artifactId>xxl-job-core</artifactId>
    <version>2.3.1</version>
</dependency>
1
2
3
4
5

# 2、application.yml配置文件

xxl:
  job:
    admin:
      addresses: http://localhost:8080/xxl-job-admin
      accessToken: xxl666
    executor:
      appname: xxl-job-executor-sample # 给你的执行器起个名字
1
2
3
4
5
6
7

# 3、创建配置文件

@Slf4j
@Component
public class XxlJobConfig {

    @Value("${xxl.job.admin.addresses}")
    private String adminAddresses;
    @Value("${xxl.job.admin.accessToken}")
    private String accessToken;
    @Value("${xxl.job.executor.appname}")
    private String appname;

    @Bean
    public XxlJobSpringExecutor xxlJobExecutor() {
        log.info(">>>>>>>>>>> xxl-job config init.");
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
        xxlJobSpringExecutor.setAppname(appname);
        xxlJobSpringExecutor.setAccessToken(accessToken);
        return xxlJobSpringExecutor;
    }

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
最近修改于: 2024/5/27 00:36:01
和宇宙温柔的关联
房东的猫