38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
package com.xkrs.common.config;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.scheduling.TaskScheduler;
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
/**
|
|
* WebMVC配置
|
|
* @author Tajochen
|
|
*/
|
|
@Configuration
|
|
public class MvcConfig implements WebMvcConfigurer {
|
|
|
|
/**
|
|
* 放行跨域请求
|
|
*/
|
|
@Override
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
registry.addMapping("/**")
|
|
.allowedOrigins("*")
|
|
.allowedMethods("*")
|
|
.allowedHeaders("*");
|
|
}
|
|
|
|
/**
|
|
* 定时任务线程池更改,防止多个任务并行
|
|
*/
|
|
@Bean
|
|
public TaskScheduler taskScheduler() {
|
|
final ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
|
scheduler.setPoolSize(5);
|
|
return scheduler;
|
|
}
|
|
}
|