1參數拼裝
https://blog.yeskery.com/articles/345298282
WxWebMvcConfiguration
HandlerMethodArgumentResolver
2 全局異常處理
https://blog.csdn.net/weixin_40792878/article/details/81915712
@ControllerAdvice @ExceptionHandler
地址:
https://github.com/linlinjava/litemall
3、異步任務
@EnableAsync
@Async
@Configuration @EnableAsync public class ThreadPoolTaskConfig { private static final int corePoolSize = 10; // 核心線程數(默認線程數) private static final int maxPoolSize = 100; // 最大線程數 private static final int keepAliveTime = 10; // 允許線程空閑時間(單位:默認為秒) private static final int queueCapacity = 200; // 緩沖隊列數 private static final String threadNamePrefix = "Async-Service-"; // 線程池名前綴 @Bean("taskExecutor") // bean的名稱,默認為首字母小寫的方法名 public ThreadPoolTaskExecutor taskExecutor(){ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); executor.setKeepAliveSeconds(keepAliveTime); executor.setThreadNamePrefix(threadNamePrefix); // 線程池對拒絕任務的處理策略 executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); // 初始化 executor.initialize(); return executor; } } @Service public class testAsyncService { Logger log = LoggerFactory.getLogger(testAsyncService.class); // 發送提醒短信 1 @Async("taskExecutor") public void service1() throws InterruptedException { log.info("--------start-service1------------"); Thread.sleep(5000); // 模擬耗時 log.info("--------end-service1------------"); } }