This commit is contained in:
2023-07-26 18:00:52 +08:00
parent 6da2167e58
commit 27a422b841
6 changed files with 81 additions and 13 deletions

11
pom.xml
View File

@@ -51,6 +51,17 @@
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-quartz -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
<dependency>
<groupId>eu.bitwalker</groupId>
<artifactId>UserAgentUtils</artifactId>

View File

@@ -18,16 +18,4 @@ import java.util.concurrent.Executor;
public class AsyncConfig implements AsyncConfigurer {
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
threadPoolTaskExecutor.initialize();
return threadPoolTaskExecutor;
}
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return (ex, method, params) -> log.info("异步方法异常:\nmethod: {}\nparams: {}", method.toString(), Arrays.toString(params), ex);
}
}

View File

@@ -0,0 +1,23 @@
package cn.lihongjie.coal.config;
import org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCustomizer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.time.Duration;
@EnableCaching
@Configuration
public class CacheConfig {
@Bean
public RedisCacheManagerBuilderCustomizer myRedisCacheManagerBuilderCustomizer() {
return new RedisCacheManagerBuilderCustomizer() {
@Override
public void customize(org.springframework.data.redis.cache.RedisCacheManager.RedisCacheManagerBuilder builder) {
}
};
}
}

View File

@@ -0,0 +1,12 @@
package cn.lihongjie.coal.job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
public class DemoJob extends QuartzJobBean {
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
}
}

View File

@@ -21,4 +21,28 @@ spring:
validation-query-timeout: 1000
test-on-borrow: true
test-on-return: true
enable: true
enable: true
task:
execution:
pool:
max-size: 20
queue-capacity: 1000
thread-name-prefix: task-
scheduling:
thread-name-prefix: schedule-
data:
redis:
host: localhost
port: 6379
password: 'abc@123'
cache:
type: redis
redis:
enable-statistics: true
quartz:
auto-startup: true
job-store-type: jdbc
overwrite-existing-jobs: true
wait-for-jobs-to-complete-on-shutdown: true
startup-delay: 5

View File

@@ -0,0 +1,10 @@
<configuration>
<springProfile name="dev | test">
<!-- configuration to be enabled when the "dev" or "staging" profiles are active -->
<include ></include>
</springProfile>
<springProfile name="production">
<!-- configuration to be enabled when the "production" profile is not active -->
</springProfile>
</configuration>