当前位置:网站首页>Use of applicationreadyevent
Use of applicationreadyevent
2022-04-23 08:22:00 【As young as】
Preface
about ApplicationReadyEvent, The explanation on the official website is : Events are released as late as possible , To indicate that the application is ready to service the request . The source of this event is SpringApplication In itself , But pay attention to modifying its internal state , Because then all initialization steps will be completed . As the name suggests, it is SpringApplication Events after readiness , We can put some operations that may have class uninitialized exceptions into it to execute
Use
@Component
public class BackendReadyEventListener implements ApplicationListener<ApplicationReadyEvent> {
private static final Logger LOGGER = LoggerFactory.getLogger(BackendReadyEventListener.class);
@Value("${thread.pool.coreSize:5}")
private int corePoolSize;
@Value("${thread.pool.maxSize:50}")
private int maxPoolSize;
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
// Profile database cache initialization
ConfigHelper configHelper = SpringContextUtils.getBean(ConfigHelper.class);
configHelper.initDatabaseCache();
// Initializes the thread pool
new PoolExecutor(corePoolSize, maxPoolSize, new ThreadPoolExecutor.AbortPolicy());
}
}
such as , In the above code, I have performed operations such as initializing the configuration file database cache and initializing the thread pool
版权声明
本文为[As young as]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230703560953.html
边栏推荐
- 基于TCP/IP协议的网络通信实例——文件传输
- [explanation] get ora-12838: cannot read / modify an object after modifying it in parallel
- dried food! Point based: differentiable Poisson solver
- 5.6 综合案例-RTU-
- 一个必看的微信小程序开发指南1-基础知识了解
- 396. Rotate Function
- DOM 学习之—添加+-按钮
- Flink SQL实现流批一体
- 对OutputStream类的flush()方法的误解
- Vowel substring in statistical string of leetcode simple problem
猜你喜欢
随机推荐
Sword finger offer Day24 math (medium)
ajax防止缓存方法
监控智能回放是什么,如何使用智能回放查询录像
Online yaml to XML tool
QT reading and writing XML files
谈谈那些基础但不简单的股票数据
Notes on English class (4)
The whole house intelligence bet by the giant is driving the "self revolution" of Hisense, Huawei and Xiaomi
Find the largest of 3 strings (no more than 20 characters per string).
Green apple film and television system source code film and television aggregation film and television navigation film and television on demand website source code
【解释】get ORA-12838: cannot read/modify an object after modifying it in parallel
Rearranging log files for leetcode simple question
5.6 综合案例-RTU-
Somme numérique de la chaîne de calcul pour un problème simple de leetcode
Qt利用QtXlsx操作excel文件
idea:使用easyYapi插件导出yapi接口
SYS_CONNECT_BY_PATH(column,'char') 结合 start with ... connect by prior
Situational leaders - Chapter 7, solving performance problems
Qt读取路径下所有文件或指定类型文件(含递归、判断是否为空、创建路径)
记录:js删除数组中某一项或几项的几种方法