没有合适的资源?快使用搜索试试~ 我知道了~
spring的监听器和缓存.docx
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 57 浏览量
2022-06-26
21:04:23
上传
评论
收藏 20KB DOCX 举报
温馨提示
试读
8页
@Slf4j public class MyListener implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent sce) { log.info("web项目的启动{} 一开始就启动",sce.getServletContext()); System.err.println("web项目的启动{}"); } @Override public void contextDestroyed(ServletContextEvent sce) { log.info("web项目的关闭{}........................."); System.err.println("web项目的关闭{}............................"); } }
资源推荐
资源详情
资源评论
spring 的监听器和缓存
Springboot 中使用监听器
一、传统的方法(configguration)
@Slf4j
public class MyListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent sce) {
log.info("web 项目的启动{} 一开始就启动",sce.getServletContext());
System.err.println("web 项目的启动{}");
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
log.info("web 项目的关闭{}.........................");
System.err.println("web 项目的关闭{}............................");
}
}
把监听器给 springboot
@Configuration
public class ListenerConfig {
@Bean
public ServletListenerRegistrationBean myListener() {
ServletListenerRegistrationBean<MyListener> registrationBean = new
ServletListenerRegistrationBean<>(new MyListener());
资源评论
小兔子平安
- 粉丝: 209
- 资源: 1940
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功