feat: There is no way the scheduled conf
This commit is contained in:
@@ -24,6 +24,11 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- scheduled所属资源为spring-context-support -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-convert</artifactId>
|
||||
|
||||
@@ -12,11 +12,13 @@ import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerF
|
||||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@EnableEurekaClient
|
||||
@EnableFeignClients
|
||||
@ServletComponentScan
|
||||
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
|
||||
@EnableScheduling
|
||||
@MapperScan(value = {"com.adc.da.file.store"})
|
||||
public class AdcDaApplication {
|
||||
|
||||
|
||||
@@ -152,3 +152,8 @@ elas.flag=true
|
||||
# 文档转换TCP通讯地址
|
||||
convert.host=127.0.0.1
|
||||
#convert.host=0.0.0.0
|
||||
|
||||
# =============================================================================
|
||||
# scheduled 配置
|
||||
# =============================================================================
|
||||
isNotScheduled=false
|
||||
@@ -11,6 +11,11 @@
|
||||
|
||||
<artifactId>adc-da-slrs</artifactId>
|
||||
<dependencies>
|
||||
<!-- scheduled所属资源为spring-context-support -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-base</artifactId>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.adc.da.scheduled;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@EnableScheduling
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ScheduledJob {
|
||||
|
||||
/**
|
||||
* 根据配置文件设置是否开启定时器
|
||||
*/
|
||||
|
||||
@Value("${isNotScheduled}")
|
||||
private boolean isNotScheduled; //是否开启定时器
|
||||
|
||||
|
||||
@Scheduled(cron="*/5 * * * * ?")
|
||||
@Async
|
||||
public void StandScheduledJob(){
|
||||
if(isNotScheduled){
|
||||
System.out.println(Thread.currentThread().getName() + " cron=0 0 1 1 * ? --- " + new Date()+"---START-01");
|
||||
System.out.println(Thread.currentThread().getName() + " cron=0 0 1 1 * ? --- " + new Date()+"---End-01");
|
||||
try{
|
||||
Thread.sleep(2000);
|
||||
}catch(Exception e){
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user