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
package io.better.toutiao.config;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import io.better.toutiao.properties.XxlJobProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* The type Xxl job config.
*
* @author better create in 2019-04-28 10:27
*/
@Configuration
public class XxlJobConfig {
/**
* Xxl job executor xxl job spring executor.
*
* @param xxlJobProperties the xxl job properties
* @return the xxl job spring executor
*/
@Bean(initMethod = "start", destroyMethod = "destroy")
@ConditionalOnMissingBean(value = XxlJobSpringExecutor.class)
public XxlJobSpringExecutor xxlJobExecutor(XxlJobProperties xxlJobProperties) {
XxlJobSpringExecutor xxlJobExecutor = new XxlJobSpringExecutor();
xxlJobExecutor.setIp(xxlJobProperties.getIp());
xxlJobExecutor.setAdminAddresses(xxlJobProperties.getAdminAddresses());
xxlJobExecutor.setPort(xxlJobProperties.getPort());
xxlJobExecutor.setLogPath(xxlJobProperties.getLogPath());
xxlJobExecutor.setAppName(xxlJobProperties.getAppName());
xxlJobExecutor.setAccessToken(xxlJobProperties.getAccessToken());
xxlJobExecutor.setLogRetentionDays(xxlJobProperties.getLogRetentionDays());
return xxlJobExecutor;
}
}