Web服务器启动时加载缓存
来源:互联网 发布:数据交换方式有哪些 编辑:程序博客网 时间:2024/05/19 02:29
Web服务器启动时加载缓存
package service;import javax.annotation.PostConstruct;import org.springframework.context.annotation.Lazy;import org.springframework.stereotype.Component;@Lazy(false)@Componentpublic class CacheManager { @PostConstruct private void init() { System.out.println("hhh"); }}
@Lazy注解
If this annotation is not present on a @Component or @Bean definition, eager initialization will occur. If present and set to true, the @Bean or @Component will not be initialized until referenced by another bean or explicitly retrieved from the enclosing BeanFactory. If present and set to false, the bean will be instantiated on startup by bean factories that perform eager initialization of singletons.
只要不设置成true,这里不用此注解或者设置为false,都能实现主动初始化
@PostConstruct注解
The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization. This method MUST be invoked before the class is put into service. This annotation MUST be supported on all classes that support dependency injection. The method annotated with PostConstruct MUST be invoked even if the class does not request any resources to be injected. Only one method can be annotated with this annotation.
在方法上加上此注解即可实现Web服务器启动时做一些自定义的逻辑,例如实现自己的程序的缓存加载
- Web服务器启动时加载缓存
- Java web服务器启动时加载
- 服务器启动时,web.xml配置加载顺序解释
- WEB服务器启动时加载一个ServerSocket服务
- Tomcat启动时加载数据到缓存[web.xml中listener加载顺序]
- vs2015 加载项目的时启动:无法启动 IIS Express Web 服务器
- Tomcat启动时加载数据到缓存---web.xml中listener加载顺序(优先初始化Spring IOC容器)
- Tomcat启动时加载数据到缓存--Web.xml里listener的加载顺序,优先初始化Spring IOC容器
- spring启动时加载缓存中数据
- 项目启动加载缓存
- 服务器启动时Webapp的web.xml中配置的加载顺序
- 服务器启动时Webapp的web.xml中配置的加载顺序
- 服务器启动时Webapp的web.xml中配置的加载顺序
- 服务器启动时Webapp的web.xml中配置的加载顺序
- 服务器启动时Webapp的web.xml中配置的加载顺序
- 服务器启动时Webapp的web.xml中配置的加载顺序
- 服务器启动时Webapp的web.xml中配置的加载顺序(转
- 搭建web缓存服务器
- 使用Fragment应用放置后台很久被系统回收出现crash
- git学习笔记-----第一次提交
- Android自定义控件—CouponsView
- 队列和堆栈
- GreenDao使用CRUD及数据库结构升级
- Web服务器启动时加载缓存
- drawRect方法&贝塞尔路径&上下文
- 【light-oj】-1104 - Birthday Paradox(数学,概率)
- 发布web总结
- python的import与from...import的不同之处
- CoreData初识
- 大数据入门,你需要懂这四个常识
- Wireshark的Pcap文件格式分析及解析源码
- UILineBreakMode的用法解释