package cn.besteam; import cn.besteam.common.api.vo.Result; import cn.besteam.common.aspect.annotation.OpenApi; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; import springfox.documentation.swagger2.annotations.EnableSwagger2; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.concurrent.Executor; @EnableSwagger2 @SpringBootApplication @EnableAsync // @EnableScheduling public class BackendApplication { public static void main(String[] args) { SpringApplication.run(BackendApplication.class, args); } @Bean public Executor taskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(2); executor.setMaxPoolSize(200); executor.setQueueCapacity(500); executor.setThreadNamePrefix("Task-"); executor.initialize(); return executor; } @Controller public class MainController { @GetMapping("/echo") @ResponseBody @OpenApi public Result echo() { return Result.ok("在线中..."); } @GetMapping("/") @OpenApi public void index(HttpServletResponse response) throws IOException { response.sendRedirect("doc.html"); } } }