-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
/
Copy pathXxlJobAutoConfiguration.java
33 lines (29 loc) · 1.36 KB
/
XxlJobAutoConfiguration.java
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
package com.xxl.job.autoconfigure;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author linyunlong
*/
@Configuration
@EnableConfigurationProperties(XxlJobProperties.class)
@ConditionalOnProperty(value = "xxl.job.enabled", havingValue = "true", matchIfMissing = true)
public class XxlJobAutoConfiguration {
@ConditionalOnMissingBean(XxlJobSpringExecutor.class)
@Bean
public XxlJobSpringExecutor xxlJobSpringExecutor(XxlJobProperties properties) {
XxlJobSpringExecutor executor = new XxlJobSpringExecutor();
executor.setAdminAddresses(properties.getAdminAddress());
executor.setAccessToken(properties.getAccessToken());
executor.setAppname(properties.getAppName());
executor.setAddress(properties.getAddress());
executor.setIp(properties.getIp());
executor.setPort(properties.getPort());
executor.setLogPath(properties.getLogPath());
executor.setLogRetentionDays(properties.getLogRetentionDays());
return executor;
}
}