当前位置:网站首页>3. integrate listener
3. integrate listener
2022-06-28 20:10:00 【Yuyy】
This paper is finally updated at 915 Days ago, , The information may have developed or changed .
Complete with annotation scan Listener Registration of components
- 1.1 To write Listener
/*** springBoot Integrate Listener
<listener>
<listener-class>com.bjsxt.listener.FirstListener</listener-class>
</listener> @WebListener
public class FirstListener implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void contextInitialized(ServletContextEvent arg0) {
System.out.println("Listener...init......");
}
}- 1.2 Write the startup class
/*** springBoot Integrate Listener Mode one ***/
@SpringBootApplication @ServletComponentScan
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}To complete by means of Listener Component registration
- 2.1 To write Listener
/*** springBoot Integrate Listener Mode two . ***/
public class SecondListener implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void contextInitialized(ServletContextEvent arg0) {
System.out.println("SecondListener..init.....");
}
}- 2.2 Write the startup class
/*** SpringBoot Integrate Listener Mode two ***/
@SpringBootApplication
public class App2 {
public static void main(String[] args) {
SpringApplication.run(App2.class, args);
}
/*** register listener */
@Bean
public ServletListenerRegistrationBean<SecondListener> getServletListenerRegistrationBean(){
ServletListenerRegistrationBean<SecondListener> bean= new ServletListenerRegistrationBean<SecondListener>(new SecondListener());
return bean;
}
}Post Views: 384
边栏推荐
- 3. 整合 Listener
- Class loading mechanism and object creation
- Database learning notes (sql04)
- Kaggle腸胃道圖像分割比賽baseline
- 类加载机制与对象的创建
- 阿里开源(EasyExcel)
- 实型数运算
- 修复一次flutter 无法选中模拟器
- The first meta universe concept novel, meta universe 2086, won the upper attack meta universe award in 2022
- Demo of intelligent computing system 2 bangc operator development (heterogeneous programming flow of CPU and mlu270)
猜你喜欢

【算法篇】刷了两道大厂面试题,含泪 ”重学数组“

Number theory -- detailed proof of Euler function, sieve method for Euler function, Euler theorem and Fermat theorem

Jenkins pipeline's handling of job parameters

2022焊工(初级)特种作业证考试题库及答案

30讲 线性代数 第四讲 线性方程组

Xiaobai's e-commerce business is very important to choose the right mall system!

电子科大(申恒涛团队)&京东AI(梅涛团队)提出用于视频问答的结构化双流注意网络,性能SOTA!优于基于双视频表示的方法!...

Parallax JS special effect JS carousel map plug-in

严重性 代码 说明 项目 文件 行 禁止显示状态 错误 LNK2038 检测到“RuntimeLibrary”的不匹配项: 值“MD_DynamicRelease”不匹配值“MDd_DynamicDe

2022年T电梯修理考试题库模拟考试平台操作
随机推荐
Xiaobai's e-commerce business is very important to choose the right mall system!
秒杀系统设计
Kettle (VI): full database backup based on kettle
kettle(六):基于Kettle的数据库全量备份
redisTemplate
jvm内存结构
2022 welder (elementary) special operation certificate examination question bank and answers
Racher add / delete node
Number theory -- detailed proof of Euler function, sieve method for Euler function, Euler theorem and Fermat theorem
关键字long
H5 sunflower operation
2837. The total number of teams
5G NR MBS架构介绍
压缩与解压缩命令
R language GLM generalized linear model: logistic regression, Poisson regression fitting mouse clinical trial data (dose and response) examples and self-test questions
2022 P cylinder filling test exercises and online simulation test
risc-v指令集
怎么理解云原生数据库的快速迭代?
Gaozelong, a digital economy expert: Yingke changed its name to yingcosmos. Will yuancosmos become the next growth engine of Yingke?
[324. swing sequence II]