最佳实践--Spring容器初始化完成之后执行某个方法
来源:互联网 发布:solr数据没有了 编辑:程序博客网 时间:2024/06/05 03:54
在做javaweb项目的时候,当用户访问的时候需要从数据库加载数据,现在要在容器初始化完成之后直接把数据放入缓存,当用户访问的时候提高速度。
查阅相关spring文档,找到了一个最佳实践(best practice)
The JSR-250 @PostConstruct and @PreDestroy annotations are generally considered best practice for receiving lifecycle callbacks in a modern Spring application. Using these annotations means that your beans are not coupled to Spring specific interfaces. For details see Section 6.9.8, “@PostConstruct and @PreDestroy”.
If you don’t want to use the JSR-250 annotations but you are still looking to remove coupling consider the use of init-method and destroy-method object definition metadata.
详情看参考文献
直接上代码
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
0 0
- 最佳实践--Spring容器初始化完成之后执行某个方法
- 最佳实践--Spring容器初始化完成之后执行某个方法
- Spring容器初始化完之后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- 当spring 容器初始化完成后执行某个方法
- require.js学习笔记
- numpy 傅里叶变换与反变换高低通滤波与带通滤波
- 闲谈:感知器学习算法(The perceptron learning algorithm)
- hive导出数据的几种方式
- 前端开发 AMD 和 CMD 的规范区别
- 最佳实践--Spring容器初始化完成之后执行某个方法
- 简单的前端表单的校验
- uboot 简单的执行流程之我见
- ThreadPoolExecutor讲解
- EasyUI datagrid回车下一个
- android studio快速添加lambda的支持
- Jsoup发送get和post请求
- Handler机制
- 二叉树