123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package com.gxzc.zen.job.config
- import com.xxl.job.core.executor.XxlJobExecutor
- import org.mybatis.spring.annotation.MapperScan
- import org.slf4j.LoggerFactory
- import org.springframework.beans.factory.annotation.Value
- import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
- import org.springframework.context.annotation.Bean
- import org.springframework.context.annotation.Configuration
- /**
- *
- * @author NorthLan at 2018/2/8
- */
- @Configuration
- @ConditionalOnProperty(prefix = "xxl.job", name = ["enable"], havingValue = "true", matchIfMissing = true)
- @MapperScan(basePackages = ["com.gxzc.zen.job.jobhandler"])
- class XxlJobConfig {
- companion object {
- private val logger = LoggerFactory.getLogger(XxlJobConfig::class.java)
- }
- @Value("\${xxl.job.admin.address}")
- private val adminAddress: String? = null
- @Value("\${xxl.job.executor.appname}")
- private val appName: String? = null
- @Value("\${xxl.job.executor.ip}")
- private val ip: String? = null
- @Value("\${xxl.job.executor.port}")
- private val port: Int = 0
- @Value("\${xxl.job.accessToken}")
- private val accessToken: String? = null
- @Value("\${xxl.job.executor.logpath}")
- private val logPath: String? = null
- @Value("\${xxl.job.executor.logretentiondays}")
- private val logRetentionDays: Int = 0
- @Bean
- fun xxlJobExecutor(): XxlJobExecutor {
- logger.info(">>>>>>>>>>>> xxl-job executor config init...")
- return XxlJobExecutor().also {
- it.setAdminAddresses(adminAddress)
- it.setAppName(appName)
- it.setIp(ip)
- it.setPort(port)
- it.setAccessToken(accessToken)
- it.setLogPath(logPath)
- it.setLogRetentionDays(logRetentionDays)
- }
- }
- }
|