|
@@ -1,11 +1,46 @@
|
1
|
1
|
package com.xxl.job.executor.core.config;
|
2
|
2
|
|
|
3
|
+import com.xxl.job.core.executor.XxlJobExecutor;
|
|
4
|
+import org.slf4j.Logger;
|
|
5
|
+import org.slf4j.LoggerFactory;
|
|
6
|
+import org.springframework.beans.factory.annotation.Value;
|
|
7
|
+import org.springframework.context.annotation.Bean;
|
|
8
|
+import org.springframework.context.annotation.ComponentScan;
|
3
|
9
|
import org.springframework.context.annotation.Configuration;
|
4
|
|
-import org.springframework.context.annotation.ImportResource;
|
5
|
10
|
|
6
|
11
|
|
7
|
12
|
@Configuration
|
8
|
|
-@ImportResource("classpath:applicationcontext-xxl-job.xml")
|
|
13
|
+@ComponentScan(basePackages = "com.xxl.job.executor.service.jobhandler")
|
9
|
14
|
public class XxlJobConfig {
|
|
15
|
+ private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+ @Value("${xxl.job.admin.addresses}")
|
|
19
|
+ private String addresses;
|
|
20
|
+
|
|
21
|
+ @Value("${xxl.job.executor.appname}")
|
|
22
|
+ private String appname;
|
|
23
|
+
|
|
24
|
+ @Value("${xxl.job.executor.ip}")
|
|
25
|
+ private String ip;
|
|
26
|
+
|
|
27
|
+ @Value("${xxl.job.executor.port}")
|
|
28
|
+ private int port;
|
|
29
|
+
|
|
30
|
+ @Value("${xxl.job.executor.logpath}")
|
|
31
|
+ private String logpath;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+ @Bean(initMethod = "start", destroyMethod = "destroy")
|
|
35
|
+ public XxlJobExecutor xxlJobExecutor() {
|
|
36
|
+ logger.error("------------ xxlJobExecutor -----------");
|
|
37
|
+ XxlJobExecutor xxlJobExecutor = new XxlJobExecutor();
|
|
38
|
+ xxlJobExecutor.setIp(ip);
|
|
39
|
+ xxlJobExecutor.setPort(port);
|
|
40
|
+ xxlJobExecutor.setAppName(appname);
|
|
41
|
+ xxlJobExecutor.setAdminAddresses(addresses);
|
|
42
|
+ xxlJobExecutor.setLogPath(logpath);
|
|
43
|
+ return xxlJobExecutor;
|
|
44
|
+ }
|
10
|
45
|
|
11
|
46
|
}
|