refactor: 修改异步方法的配置
This commit is contained in:
parent
591a3836b4
commit
3229773d6e
|
@ -10,7 +10,6 @@ import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
|
|||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication(exclude = {
|
||||
|
@ -24,7 +23,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
JmeterProperties.class
|
||||
})
|
||||
@EnableScheduling
|
||||
@EnableAsync(proxyTargetClass = true)
|
||||
//@PropertySource(value = {"file:c:\\opt\\metersphere\\conf\\metersphere.properties"}, encoding = "UTF-8", ignoreResourceNotFound = true)
|
||||
@PropertySource(value = {"file:/opt/metersphere/conf/metersphere.properties"}, encoding = "UTF-8", ignoreResourceNotFound = true)
|
||||
public class Application {
|
||||
|
|
|
@ -6,6 +6,8 @@ import org.springframework.core.task.AsyncTaskExecutor;
|
|||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
@EnableAsync(proxyTargetClass = true)
|
||||
@Configuration
|
||||
public class AsyncConfig {
|
||||
|
@ -13,9 +15,9 @@ public class AsyncConfig {
|
|||
@Bean
|
||||
public AsyncTaskExecutor taskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setThreadNamePrefix("Async-Executor");
|
||||
executor.setCorePoolSize(5);
|
||||
executor.setMaxPoolSize(10);
|
||||
executor.setThreadNamePrefix("Async-Executor-");
|
||||
executor.setCorePoolSize(10);
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue