fys
This commit is contained in:
46
fys-common/fys-common-job/pom.xml
Normal file
46
fys-common/fys-common-job/pom.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>fys-common-job</artifactId>
|
||||
|
||||
<description>
|
||||
fys-common-job 定时任务
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SnailJob client -->
|
||||
<dependency>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>snail-job-client-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>snail-job-client-job-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,37 @@
|
||||
package com.fuyuanshen.common.job.config;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import com.aizuda.snailjob.client.common.appender.SnailLogbackAppender;
|
||||
import com.aizuda.snailjob.client.common.event.SnailClientStartingEvent;
|
||||
import com.aizuda.snailjob.client.starter.EnableSnailJob;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 启动定时任务
|
||||
*
|
||||
* @author opensnail
|
||||
* @date 2024-05-17
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ConditionalOnProperty(prefix = "snail-job", name = "enabled", havingValue = "true")
|
||||
@EnableScheduling
|
||||
@EnableSnailJob
|
||||
public class SnailJobConfig {
|
||||
|
||||
@EventListener(SnailClientStartingEvent.class)
|
||||
public void onStarting(SnailClientStartingEvent event) {
|
||||
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
SnailLogbackAppender<ILoggingEvent> ca = new SnailLogbackAppender<>();
|
||||
ca.setName("snail_log_appender");
|
||||
ca.start();
|
||||
Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
|
||||
rootLogger.addAppender(ca);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
com.fuyuanshen.common.job.config.SnailJobConfig
|
Reference in New Issue
Block a user