kaiyu
2021-06-10 ddebb2ea352012c10ec31a9d9774b0320af4caac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package com.moral.api.config.xxl;
 
 
import lombok.extern.slf4j.Slf4j;
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.ComponentScan;
import org.springframework.context.annotation.Configuration;
 
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
 
@Configuration
@ComponentScan(basePackages = "com.moral.api.jobHandler")
@Slf4j
public class XxlJobConfig {
 
    @Value("${xxl.job.admin.addresses}")
    private String adminAddresses;
 
    @Value("${xxl.job.executor.appname}")
    private String appName;
 
    @Value("${xxl.job.executor.ip}")
    private String ip;
 
    @Value("${xxl.job.executor.port}")
    private Integer port;
 
    @Value("${xxl.job.accessToken}")
    private String accessToken;
 
    @Value("${xxl.job.executor.logpath}")
    private String logPath;
 
    @Value("${xxl.job.executor.logretentiondays}")
    private Integer logRetentionDays;
 
    @Bean
    public XxlJobSpringExecutor xxlJobSpringExecutor(){
        log.info("xxl jon config init");
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
        xxlJobSpringExecutor.setAppname(appName);
        xxlJobSpringExecutor.setIp(ip);
        xxlJobSpringExecutor.setPort(port);
        xxlJobSpringExecutor.setAccessToken(accessToken);
        xxlJobSpringExecutor.setLogPath(logPath);
        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
        return xxlJobSpringExecutor;
    }
 
    @Override
    public String toString() {
        return "XxlJobConfig{" +
                "adminAddresses='" + adminAddresses + '\'' +
                ", appName='" + appName + '\'' +
                ", ip='" + ip + '\'' +
                ", port=" + port +
                ", accessToken='" + accessToken + '\'' +
                ", logPath='" + logPath + '\'' +
                ", logRetentionDays=" + logRetentionDays +
                '}';
    }
 
    public XxlJobConfig() {
    }
 
    public XxlJobConfig(String adminAddresses, String appName, String ip, Integer port, String accessToken, String logPath, Integer logRetentionDays) {
        this.adminAddresses = adminAddresses;
        this.appName = appName;
        this.ip = ip;
        this.port = port;
        this.accessToken = accessToken;
        this.logPath = logPath;
        this.logRetentionDays = logRetentionDays;
    }
 
    public String getAdminAddresses() {
        return adminAddresses;
    }
 
    public void setAdminAddresses(String adminAddresses) {
        this.adminAddresses = adminAddresses;
    }
 
    public String getAppName() {
        return appName;
    }
 
    public void setAppName(String appName) {
        this.appName = appName;
    }
 
    public String getIp() {
        return ip;
    }
 
    public void setIp(String ip) {
        this.ip = ip;
    }
 
    public Integer getPort() {
        return port;
    }
 
    public void setPort(Integer port) {
        this.port = port;
    }
 
    public String getAccessToken() {
        return accessToken;
    }
 
    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }
 
    public String getLogPath() {
        return logPath;
    }
 
    public void setLogPath(String logPath) {
        this.logPath = logPath;
    }
 
    public Integer getLogRetentionDays() {
        return logRetentionDays;
    }
 
    public void setLogRetentionDays(Integer logRetentionDays) {
        this.logRetentionDays = logRetentionDays;
    }
}