add [重大更新]增加 ruoyi-job 任务调度模块(基于xxl-job)
parent
82f1f5d0cf
commit
aaa15b403a
@ -0,0 +1,39 @@
|
||||
<?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">
|
||||
<parent>
|
||||
<artifactId>ruoyi-vue-plus</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>ruoyi-job</artifactId>
|
||||
|
||||
<description>
|
||||
任务调度
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- xxl-job-core -->
|
||||
<dependency>
|
||||
<groupId>com.xuxueli</groupId>
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<artifactId>tlog-xxl-job</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,44 @@
|
||||
package com.ruoyi.job.config;
|
||||
|
||||
import com.ruoyi.job.config.properties.XxlJobProperties;
|
||||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||||
import com.yomahub.tlog.springboot.lifecircle.TLogXxljobEnhanceInit;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* xxl-job config
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@EnableConfigurationProperties(XxlJobProperties.class)
|
||||
@AllArgsConstructor
|
||||
public class XxlJobConfig {
|
||||
|
||||
private final XxlJobProperties xxlJobProperties;
|
||||
|
||||
@Bean
|
||||
public XxlJobSpringExecutor xxlJobExecutor() {
|
||||
log.info(">>>>>>>>>>> xxl-job config init.");
|
||||
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
||||
xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdminAddresses());
|
||||
xxlJobSpringExecutor.setAccessToken(xxlJobProperties.getAccessToken());
|
||||
XxlJobProperties.Executor executor = xxlJobProperties.getExecutor();
|
||||
xxlJobSpringExecutor.setAppname(executor.getAppname());
|
||||
xxlJobSpringExecutor.setAddress(executor.getAddress());
|
||||
xxlJobSpringExecutor.setIp(executor.getIp());
|
||||
xxlJobSpringExecutor.setPort(executor.getPort());
|
||||
xxlJobSpringExecutor.setLogPath(executor.getLogPath());
|
||||
xxlJobSpringExecutor.setLogRetentionDays(executor.getLogRetentionDays());
|
||||
return xxlJobSpringExecutor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TLogXxljobEnhanceInit tLogXxljobEnhanceInit(){
|
||||
return new TLogXxljobEnhanceInit();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.ruoyi.job.config.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* xxljob配置类
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "xxl.job")
|
||||
public class XxlJobProperties {
|
||||
|
||||
private String adminAddresses;
|
||||
|
||||
private String accessToken;
|
||||
|
||||
private Executor executor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class Executor {
|
||||
|
||||
private String appname;
|
||||
|
||||
private String address;
|
||||
|
||||
private String ip;
|
||||
|
||||
private int port;
|
||||
|
||||
private String logPath;
|
||||
|
||||
private int logRetentionDays;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue