springboot中的一些好用注解

一、sprinboot配置文件bean  @ConfigurationProperties

    https://www.jianshu.com/p/7f75936b573b

 

二、线程池配置bean  @EnableAsync、@Async

@Configuration
@EnableAsync
public class ThreadPoolConfig {
    private static final Logger logger = LoggerFactory.getLogger(ThreadPoolConfig.class);

    @Bean
    public Executor asyncServiceExecutor(){
        logger.info("start asyncServiceExecutor");
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(6);
        executor.setMaxPoolSize(12);
        executor.setQueueCapacity(50);
        executor.setKeepAliveSeconds(3);
        executor.setThreadNamePrefix("AsyncService-");
        executor.initialize();
        return executor;
    }
}
@Async("asyncServiceExecutor")
pulic void xxx(){
    //todo
}
posted @ 2020-01-14 08:58  小小爬虫  阅读(272)  评论(0编辑  收藏  举报