29 lines
1.3 KiB
Java
29 lines
1.3 KiB
Java
package com.muyu.common.xxl;
|
||
|
||
import com.muyu.common.core.utils.StringUtils;
|
||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||
import lombok.extern.log4j.Log4j2;
|
||
import org.springframework.context.annotation.Bean;
|
||
import org.springframework.stereotype.Component;
|
||
|
||
@Log4j2
|
||
@Component
|
||
public class XXLJobConfig {
|
||
@Bean
|
||
public XxlJobSpringExecutor xxlJobExecutor(XxlJobProperties xxlJobProperties) {
|
||
if (StringUtils.isEmpty(xxlJobProperties.getAdminAddresses())){
|
||
throw new RuntimeException("请在bootstrap.yml当中配置shared-configs项,xxl-job共享配置[application-xxl-config]");
|
||
}
|
||
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
||
xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdminAddresses());
|
||
xxlJobSpringExecutor.setAppname(xxlJobProperties.getAppName());
|
||
xxlJobSpringExecutor.setIp(xxlJobProperties.getIp());
|
||
xxlJobSpringExecutor.setPort(xxlJobProperties.getPort());
|
||
xxlJobSpringExecutor.setAccessToken(xxlJobProperties.getAccessToken());
|
||
xxlJobSpringExecutor.setLogPath(xxlJobProperties.getLogPath());
|
||
xxlJobSpringExecutor.setLogRetentionDays(xxlJobProperties.getLogRetentionDays());
|
||
log.info(">>>>>>>>>>> xxl-job config init success.");
|
||
return xxlJobSpringExecutor;
|
||
}
|
||
}
|