Files
cp-ems-reference/cp-ems-job/src/main/java/com/cpems/job/config/XxlJobConfig.java
Du Wenbo 8cdd8083f8 cp-ems v4.6.0 reference source code (Java/Spring Boot/RuoYi)
Enterprise EMS reference system for study purposes.
- Backend: Spring Boot + MyBatis Plus + Sa-Token
- Frontend: Vue 2 + Element UI + ECharts
- Database: MySQL + TDengine + Redis
- Features: energy monitoring, alarm management, quota, charging, maintenance
- Source: https://cp-ems.cn

This is a read-only reference. Do not develop on this repo.
2026-04-04 16:30:34 +08:00

43 lines
1.6 KiB
Java

package com.cpems.job.config;
import com.cpems.job.config.properties.XxlJobProperties;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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;
/**
* xxl-job config
*
* @author cpems
*/
@Slf4j
@Configuration
@EnableConfigurationProperties(XxlJobProperties.class)
@AllArgsConstructor
@ConditionalOnProperty(prefix = "xxl.job", name = "enabled", havingValue = "true")
public class XxlJobConfig {
private final XxlJobProperties xxlJobProperties;
@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
log.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdminAddresses());
xxlJobSpringExecutor.setAccessToken(xxlJobProperties.getAccessToken());
XxlJobProperties.Executor executor = xxlJobProperties.getExecutor();
xxlJobSpringExecutor.setAppname(executor.getAppname());
xxlJobSpringExecutor.setAddress(executor.getAddress());
xxlJobSpringExecutor.setIp(executor.getIp());
xxlJobSpringExecutor.setPort(executor.getPort());
xxlJobSpringExecutor.setLogPath(executor.getLogPath());
xxlJobSpringExecutor.setLogRetentionDays(executor.getLogRetentionDays());
return xxlJobSpringExecutor;
}
}