「xxl-executor」Springboot+xxl-job集成执行器直接复制用

admin这里忽略 详细查看官网

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


这里直接展示执行器集群 在不动以前的执行器的条件下 添加执行器 工作


废话不多说 直接上代码

依赖

    com.xuxueli    xxl-job-core    2.3.0


配置类

import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;import lombok.extern.slf4j.Slf4j;import org.springframework.boot.context.properties.ConfigurationProperties;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.context.annotation.Profile;@Profile("xxl")@Slf4j@Configurationpublic class XxlJobConfig {    @Bean    @ConfigurationProperties(prefix = "xxl.job.executor")    public XxlJobSpringExecutor xxlJobExecutor() {        log.info("xxl-job executor init.");        return new XxlJobSpringExecutor();    }}


配置文件

xxl:  job:    executor:      admin-addresses: admin地址      access-token:       appname:       port:       log-path:       log-retention-days: 30


执行类-任务

import com.xxl.job.core.context.XxlJobHelper;import com.xxl.job.core.handler.annotation.XxlJob;import org.springframework.context.annotation.Profile;import org.springframework.stereotype.Component;@Profile("xxl")@Componentpublic class MyJob{    @XxlJob("JobHandler名称")    public void execute() throws Exception {        XxlJobHelper.log("success");    }}


控制台配置

正常配置JobHandler

路由选后一个IP


额外赠送

记得开放防火墙端口

[root]#firewall-cmd --zone=public --add-port=端口/tcp --permanent[root]#firewall-cmd -reload
xxl
发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章