xxl-job 修复

pull/371/head
wuyibo 2 years ago
parent 6acd8d4271
commit 5bfbe78913

@ -1,6 +1,10 @@
package com.ruoyi.system;
import com.github.pagehelper.PageInterceptor;
import com.ruoyi.system.configProperties.XxlJobProperties;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import lombok.extern.log4j.Log4j2;
import lombok.var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
@ -15,6 +19,7 @@ import org.springframework.web.client.RestTemplate;
*
* @author ruoyi
*/
@Log4j2
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@ -50,4 +55,19 @@ public class RuoYiSystemApplication
//i.setProperties(null);
return i;
}
@Autowired
private XxlJobProperties xxlJobProperties;
@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
System.out.println(">>>>>>>>>>> xxl-job config init from nacos");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdmin().getAddresses());
xxlJobSpringExecutor.setAppname(xxlJobProperties.getExecutor().getAppname());
xxlJobSpringExecutor.setIp(xxlJobProperties.getExecutor().getIp());
xxlJobSpringExecutor.setPort(xxlJobProperties.getExecutor().getPort());
xxlJobSpringExecutor.setAccessToken(xxlJobProperties.getAccessToken());
xxlJobSpringExecutor.setLogPath(xxlJobProperties.getExecutor().getLogpath());
xxlJobSpringExecutor.setLogRetentionDays(xxlJobProperties.getExecutor().getLogretentiondays());
return xxlJobSpringExecutor;
}
}

@ -0,0 +1,53 @@
package com.ruoyi.system.configProperties;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
@Component
@Data
@ConfigurationProperties("xxl.job")
@RefreshScope
public class XxlJobProperties {
/**
* admin : {"addresses":"http://192.168.2.165:32530/xxl-job-admin"}
* executor : {"ip":null,"port":9999,"logpath":"/data/applogs/xxl-job/jobhandler","appname":"xxl-job-001"}
* accessToken : null
*/
private AdminBean admin;
private ExecutorBean executor;
private String accessToken;
@Setter
@Getter
public static class AdminBean {
/**
* addresses : http://192.168.2.165:32530/xxl-job-admin
*/
private String addresses;
}
@Setter
@Getter
public static class ExecutorBean {
/**
* ip : null
* port : 9999
* logpath : /data/applogs/xxl-job/jobhandler
* appname : xxl-job-001
*/
private String ip;
private int port;
private String logpath;
private String appname;
private int logretentiondays;
}
}
Loading…
Cancel
Save