@@ -0,0 +1,21 @@
|
||||
# base image
|
||||
FROM openjdk:21-jdk-slim
|
||||
|
||||
# maintainer
|
||||
MAINTAINER xuxueli
|
||||
|
||||
# set params
|
||||
ENV PARAMS=""
|
||||
|
||||
# set timezone
|
||||
ENV TZ=PRC
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
# copy jar
|
||||
ADD target/xxl-job-executor-sample-springboot-*.jar /app.jar
|
||||
|
||||
# command
|
||||
# log home: -e LOG_HOME=/data/applogs
|
||||
# jvm options: -e JAVA_OPTS="-Xms128m -Xmx128m"
|
||||
# app params: -e PARAMS="--server.port=8080"
|
||||
ENTRYPOINT ["sh","-c","java ${LOG_HOME:+-DLOG_HOME=$LOG_HOME} -jar $JAVA_OPTS /app.jar $PARAMS"]
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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>
|
||||
<parent>
|
||||
<groupId>com.xuxueli</groupId>
|
||||
<artifactId>xxl-job-executor-samples</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</parent>
|
||||
<artifactId>xxl-job-executor-sample-springboot</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>Example executor project for spring boot.</description>
|
||||
<url>https://www.xuxueli.com/</url>
|
||||
|
||||
<properties>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- spring-boot-starter-web (spring-webmvc + tomcat) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- xxl-job-core -->
|
||||
<dependency>
|
||||
<groupId>com.xuxueli</groupId>
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxl.job.executor;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @author xuxueli 2018-10-28 00:38:13
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class XxlJobExecutorApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(XxlJobExecutorApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.xxl.job.executor.config;
|
||||
|
||||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* xxl-job config
|
||||
*
|
||||
* @author xuxueli 2017-04-28
|
||||
*/
|
||||
@Configuration
|
||||
public class XxlJobConfig {
|
||||
private static final Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
|
||||
|
||||
@Value("${xxl.job.admin.addresses}")
|
||||
private String adminAddresses;
|
||||
|
||||
@Value("${xxl.job.admin.accessToken}")
|
||||
private String accessToken;
|
||||
|
||||
@Value("${xxl.job.admin.timeout}")
|
||||
private int timeout;
|
||||
|
||||
@Value("${xxl.job.executor.enabled}")
|
||||
private Boolean enabled;
|
||||
|
||||
@Value("${xxl.job.executor.appname}")
|
||||
private String appname;
|
||||
|
||||
@Value("${xxl.job.executor.address}")
|
||||
private String address;
|
||||
|
||||
@Value("${xxl.job.executor.ip}")
|
||||
private String ip;
|
||||
|
||||
@Value("${xxl.job.executor.port}")
|
||||
private int port;
|
||||
|
||||
@Value("${xxl.job.executor.logpath}")
|
||||
private String logPath;
|
||||
|
||||
@Value("${xxl.job.executor.logretentiondays}")
|
||||
private int logRetentionDays;
|
||||
|
||||
@Value("${xxl.job.executor.excludedpackage}")
|
||||
private String excludedPackage;
|
||||
|
||||
|
||||
@Bean
|
||||
public XxlJobSpringExecutor xxlJobExecutor() {
|
||||
logger.info(">>>>>>>>>>> xxl-job config init.");
|
||||
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
||||
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
|
||||
xxlJobSpringExecutor.setAccessToken(accessToken);
|
||||
xxlJobSpringExecutor.setTimeout(timeout);
|
||||
xxlJobSpringExecutor.setEnabled(enabled);
|
||||
xxlJobSpringExecutor.setAppname(appname);
|
||||
xxlJobSpringExecutor.setAddress(address);
|
||||
xxlJobSpringExecutor.setIp(ip);
|
||||
xxlJobSpringExecutor.setPort(port);
|
||||
xxlJobSpringExecutor.setLogPath(logPath);
|
||||
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
|
||||
xxlJobSpringExecutor.setExcludedPackage(excludedPackage);
|
||||
|
||||
return xxlJobSpringExecutor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
|
||||
*
|
||||
* 1、引入依赖:
|
||||
* <dependency>
|
||||
* <groupId>org.springframework.cloud</groupId>
|
||||
* <artifactId>spring-cloud-commons</artifactId>
|
||||
* <version>${version}</version>
|
||||
* </dependency>
|
||||
*
|
||||
* 2、配置文件,或者容器启动变量
|
||||
* spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
|
||||
*
|
||||
* 3、获取IP
|
||||
* String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//package com.xxl.job.executor.mvc.controller;
|
||||
//
|
||||
//import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
//import org.springframework.stereotype.Controller;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.ResponseBody;
|
||||
//
|
||||
//@Controller
|
||||
//@EnableAutoConfiguration
|
||||
//public class IndexController {
|
||||
//
|
||||
// @RequestMapping("/")
|
||||
// @ResponseBody
|
||||
// String index() {
|
||||
// return "xxl job executor running.";
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,389 @@
|
||||
package com.xxl.job.executor.jobhandler;
|
||||
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.xxl.tool.core.StringTool;
|
||||
import com.xxl.tool.json.GsonTool;
|
||||
import com.xxl.tool.http.HttpTool;
|
||||
import com.xxl.tool.http.http.HttpResponse;
|
||||
import com.xxl.tool.http.http.enums.ContentType;
|
||||
import com.xxl.tool.http.http.enums.Method;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* XxlJob开发示例(Bean模式)
|
||||
*
|
||||
* 开发步骤:
|
||||
* 1、任务开发:在Spring Bean实例中,开发Job方法;
|
||||
* 2、注解配置:为Job方法添加注解 "@XxlJob(value="自定义jobhandler名称", init = "JobHandler初始化方法", destroy = "JobHandler销毁方法")",注解value值对应的是调度中心新建任务的JobHandler属性的值。
|
||||
* 3、执行日志:需要通过 "XxlJobHelper.log" 打印执行日志;
|
||||
* 4、任务结果:默认任务结果为 "成功" 状态,不需要主动设置;如有诉求,比如设置任务结果为失败,可以通过 "XxlJobHelper.handleFail/handleSuccess" 自主设置任务结果;
|
||||
*
|
||||
* @author xuxueli 2019-12-11 21:52:51
|
||||
*/
|
||||
@Component
|
||||
public class SampleXxlJob {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SampleXxlJob.class);
|
||||
|
||||
|
||||
/**
|
||||
* 1、简单任务示例(Bean模式)
|
||||
*/
|
||||
@XxlJob("demoJobHandler")
|
||||
public void demoJobHandler() throws Exception {
|
||||
XxlJobHelper.log("XXL-JOB, Hello World.");
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
XxlJobHelper.log("beat at:" + i);
|
||||
TimeUnit.SECONDS.sleep(2);
|
||||
}
|
||||
// default success
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 2、分片广播任务
|
||||
*/
|
||||
@XxlJob("shardingJobHandler")
|
||||
public void shardingJobHandler() throws Exception {
|
||||
|
||||
// 分片参数
|
||||
int shardIndex = XxlJobHelper.getShardIndex();
|
||||
int shardTotal = XxlJobHelper.getShardTotal();
|
||||
|
||||
XxlJobHelper.log("分片参数:当前分片序号 = {}, 总分片数 = {}", shardIndex, shardTotal);
|
||||
|
||||
// 业务逻辑
|
||||
for (int i = 0; i < shardTotal; i++) {
|
||||
if (i == shardIndex) {
|
||||
XxlJobHelper.log("第 {} 片, 命中分片开始处理", i);
|
||||
} else {
|
||||
XxlJobHelper.log("第 {} 片, 忽略", i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 3、命令行任务
|
||||
*
|
||||
* 参数示例:"ls -a" 或者 "pwd"
|
||||
*/
|
||||
@XxlJob("commandJobHandler")
|
||||
public void commandJobHandler() throws Exception {
|
||||
String command = XxlJobHelper.getJobParam();
|
||||
int exitValue = -1;
|
||||
|
||||
BufferedReader bufferedReader = null;
|
||||
try {
|
||||
// valid
|
||||
if (command==null || command.trim().length()==0) {
|
||||
XxlJobHelper.handleFail("command empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
// command split
|
||||
String[] commandArray = command.split(" ");
|
||||
|
||||
// command process
|
||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||
processBuilder.command(commandArray);
|
||||
processBuilder.redirectErrorStream(true);
|
||||
|
||||
Process process = processBuilder.start();
|
||||
//Process process = Runtime.getRuntime().exec(command);
|
||||
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(process.getInputStream());
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(bufferedInputStream));
|
||||
|
||||
// command log
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
XxlJobHelper.log(line);
|
||||
}
|
||||
|
||||
// command exit
|
||||
process.waitFor();
|
||||
exitValue = process.exitValue();
|
||||
} catch (Exception e) {
|
||||
XxlJobHelper.log(e);
|
||||
} finally {
|
||||
if (bufferedReader != null) {
|
||||
bufferedReader.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (exitValue == 0) {
|
||||
// default success
|
||||
} else {
|
||||
XxlJobHelper.handleFail("command exit value("+exitValue+") is failed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 4、跨平台Http任务
|
||||
*
|
||||
* 参数示例:
|
||||
* <pre>
|
||||
* // 1、简单示例:
|
||||
* {
|
||||
* "url": "http://www.baidu.com",
|
||||
* "method": "get",
|
||||
* "data": "hello world"
|
||||
* }
|
||||
*
|
||||
* // 2、完整参数示例:
|
||||
* {
|
||||
* "url": "http://www.baidu.com",
|
||||
* "method": "POST",
|
||||
* "contentType": "application/json",
|
||||
* "headers": {
|
||||
* "header01": "value01"
|
||||
* },
|
||||
* "cookies": {
|
||||
* "cookie01": "value01"
|
||||
* },
|
||||
* "timeout": 3000,
|
||||
* "data": "request body data",
|
||||
* "form": {
|
||||
* "key01": "value01"
|
||||
* },
|
||||
* "auth": "auth data"
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
@XxlJob("httpJobHandler")
|
||||
public void httpJobHandler() throws Exception {
|
||||
|
||||
// param data
|
||||
String param = XxlJobHelper.getJobParam();
|
||||
if (param==null || param.trim().isEmpty()) {
|
||||
XxlJobHelper.log("param["+ param +"] invalid.");
|
||||
|
||||
XxlJobHelper.handleFail();
|
||||
return;
|
||||
}
|
||||
|
||||
// param parse
|
||||
HttpJobParam httpJobParam = null;
|
||||
try {
|
||||
httpJobParam = GsonTool.fromJson(param, HttpJobParam.class);
|
||||
} catch (Exception e) {
|
||||
XxlJobHelper.log(new RuntimeException("HttpJobParam parse error", e));
|
||||
XxlJobHelper.handleFail();
|
||||
return;
|
||||
}
|
||||
|
||||
// param valid
|
||||
if (httpJobParam == null) {
|
||||
XxlJobHelper.log("param parse fail.");
|
||||
XxlJobHelper.handleFail();
|
||||
return;
|
||||
}
|
||||
if (StringTool.isBlank(httpJobParam.getUrl())) {
|
||||
XxlJobHelper.log("url["+ httpJobParam.getUrl() +"] invalid.");
|
||||
XxlJobHelper.handleFail();
|
||||
return;
|
||||
}
|
||||
if (!isValidDomain(httpJobParam.getUrl())) {
|
||||
XxlJobHelper.log("url["+ httpJobParam.getUrl() +"] not allowed.");
|
||||
XxlJobHelper.handleFail();
|
||||
return;
|
||||
}
|
||||
Method method = Method.POST;
|
||||
if (StringTool.isNotBlank(httpJobParam.getMethod())) {
|
||||
Method methodParam = Method.valueOf(httpJobParam.getMethod().toUpperCase());
|
||||
if (methodParam == null) {
|
||||
XxlJobHelper.log("method["+ httpJobParam.getMethod() +"] invalid.");
|
||||
XxlJobHelper.handleFail();
|
||||
return;
|
||||
}
|
||||
method = methodParam;
|
||||
}
|
||||
ContentType contentType = ContentType.JSON;
|
||||
if (StringTool.isNotBlank(httpJobParam.getContentType())) {
|
||||
for (ContentType contentTypeParam : ContentType.values()) {
|
||||
if (contentTypeParam.getValue().equals(httpJobParam.getContentType())) {
|
||||
contentType = contentTypeParam;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (httpJobParam.getTimeout() <= 0) {
|
||||
httpJobParam.setTimeout(3000);
|
||||
}
|
||||
|
||||
// do request
|
||||
try {
|
||||
HttpResponse httpResponse = HttpTool.createRequest()
|
||||
.url(httpJobParam.getUrl())
|
||||
.method(method)
|
||||
.contentType(contentType)
|
||||
.header(httpJobParam.getHeaders())
|
||||
.cookie(httpJobParam.getCookies())
|
||||
.body(httpJobParam.getData())
|
||||
.form(httpJobParam.getForm())
|
||||
.auth(httpJobParam.getAuth())
|
||||
.execute();
|
||||
|
||||
XxlJobHelper.log("StatusCode: " + httpResponse.statusCode());
|
||||
XxlJobHelper.log("Response: <br>" + httpResponse.response());
|
||||
} catch (Exception e) {
|
||||
XxlJobHelper.log(e);
|
||||
XxlJobHelper.handleFail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* domain white-list, for httpJobHandler
|
||||
*/
|
||||
private static Set<String> DOMAIN_WHITE_LIST = Set.of(
|
||||
"http://www.baidu.com",
|
||||
"http://cn.bing.com"
|
||||
);
|
||||
|
||||
/**
|
||||
* valid if domain is in white-list
|
||||
*/
|
||||
private boolean isValidDomain(String url) {
|
||||
if (url == null || DOMAIN_WHITE_LIST.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (String prefix : DOMAIN_WHITE_LIST) {
|
||||
if (url.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*public static void main(String[] args) {
|
||||
HttpJobParam httpJobParam = new HttpJobParam();
|
||||
httpJobParam.setUrl("http://www.baidu.com");
|
||||
httpJobParam.setMethod(Method.POST.name());
|
||||
httpJobParam.setContentType(ContentType.JSON.getValue());
|
||||
httpJobParam.setHeaders(Map.of("header01", "value01"));
|
||||
httpJobParam.setCookies(Map.of("cookie01", "value01"));
|
||||
httpJobParam.setTimeout(3000);
|
||||
httpJobParam.setData("request body data");
|
||||
httpJobParam.setForm(Map.of("form01", "value01"));
|
||||
httpJobParam.setAuth("auth data");
|
||||
|
||||
logger.info(GsonTool.toJson(httpJobParam));
|
||||
}*/
|
||||
|
||||
/**
|
||||
* http job param
|
||||
*/
|
||||
private static class HttpJobParam{
|
||||
private String url; // 请求 Url
|
||||
private String method; // Method
|
||||
private String contentType; // Content-Type
|
||||
private Map<String, String> headers; // 存储请求头
|
||||
private Map<String, String> cookies; // Cookie(需要格式转换)
|
||||
private int timeout; // 请求超时时间
|
||||
private String data; // 存储请求体
|
||||
private Map<String, String> form; // 存储表单数据
|
||||
private String auth; // 鉴权信息
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public Map<String, String> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
public void setHeaders(Map<String, String> headers) {
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
public Map<String, String> getCookies() {
|
||||
return cookies;
|
||||
}
|
||||
|
||||
public void setCookies(Map<String, String> cookies) {
|
||||
this.cookies = cookies;
|
||||
}
|
||||
|
||||
public int getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Map<String, String> getForm() {
|
||||
return form;
|
||||
}
|
||||
|
||||
public void setForm(Map<String, String> form) {
|
||||
this.form = form;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
public void setAuth(String auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 5、生命周期任务示例:任务初始化与销毁时,支持自定义相关逻辑;
|
||||
*/
|
||||
@XxlJob(value = "demoJobHandler2", init = "init", destroy = "destroy")
|
||||
public void demoJobHandler2() throws Exception {
|
||||
XxlJobHelper.log("XXL-JOB, Hello World.");
|
||||
}
|
||||
public void init(){
|
||||
logger.info("init");
|
||||
}
|
||||
public void destroy(){
|
||||
logger.info("destroy");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
# web port
|
||||
server.port=8081
|
||||
# no web
|
||||
#spring.main.web-environment=false
|
||||
|
||||
# log config
|
||||
logging.config=classpath:logback.xml
|
||||
|
||||
|
||||
### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
|
||||
xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin
|
||||
### xxl-job access token
|
||||
xxl.job.admin.accessToken=default_token
|
||||
### xxl-job timeout by second, default 3s
|
||||
xxl.job.admin.timeout=3
|
||||
|
||||
### xxl-job executor enable, default true
|
||||
xxl.job.executor.enabled=true
|
||||
### xxl-job executor appname
|
||||
xxl.job.executor.appname=xxl-job-executor-sample
|
||||
### xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null
|
||||
xxl.job.executor.address=
|
||||
### xxl-job executor server-info
|
||||
xxl.job.executor.ip=
|
||||
xxl.job.executor.port=9999
|
||||
### xxl-job executor log-path
|
||||
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
|
||||
### xxl-job executor log-retention-days
|
||||
xxl.job.executor.logretentiondays=30
|
||||
### xxl-job executor excluded package, will skip scan job. such as "org.package01" or "org.package01,org.package02"
|
||||
xxl.job.executor.excludedpackage=
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false" scan="true" scanPeriod="1 seconds">
|
||||
|
||||
<contextName>logback</contextName>
|
||||
<property name="log.path" value="${LOG_HOME:-/data/applogs}/xxl-job/xxl-job-executor-sample-springboot.log" />
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
<!--<appender-ref ref="file"/>-->
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xxl.job.executor.test;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
public class XxlJobExecutorExampleBootApplicationTests {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
System.out.println(11);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user