开源litemall学习
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------------"); } }