mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
完善定时任务配置
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package cn.lihongjie.coal.spring.config;
|
||||
|
||||
import com.p6spy.engine.spy.P6DataSource;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import org.flywaydb.core.Flyway;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer;
|
||||
@@ -14,20 +18,24 @@ import javax.sql.DataSource;
|
||||
@Configuration
|
||||
public class QuartzConfig {
|
||||
|
||||
@Autowired
|
||||
Flyway flyway;
|
||||
@Autowired Flyway flyway;
|
||||
@Autowired private DataSource dataSource;
|
||||
|
||||
|
||||
@Bean
|
||||
public SchedulerFactoryBeanCustomizer schedulerFactoryBeanCustomizer() {
|
||||
|
||||
flyway.migrate();
|
||||
return new SchedulerFactoryBeanCustomizer() {
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void customize(SchedulerFactoryBean schedulerFactoryBean) {
|
||||
|
||||
schedulerFactoryBean.setDataSource(dataSource);
|
||||
if (dataSource instanceof P6DataSource p6DataSource) {
|
||||
schedulerFactoryBean.setDataSource(p6DataSource.unwrap(DataSource.class));
|
||||
} else {
|
||||
|
||||
schedulerFactoryBean.setDataSource(dataSource);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<property name="LOG_FILE" value="${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/${app}-${profile}.log"/>
|
||||
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||
<include resource="org/springframework/boot/logging/logback/file-appender.xml"/>
|
||||
<logger name="org.quartz" level="WARN"/>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
|
||||
Reference in New Issue
Block a user