当前位置:网站首页>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
边栏推荐
- 2280.Cupboards
- 2022焊工(初级)特种作业证考试题库及答案
- Shell reads the value of the JSON file
- Quaternion quaternion and Euler angle transformation in ROS
- 蓝桥杯 历届试题 蚂蚁感冒
- Why is it not enough to declare the structure alias when using the structure variable of other files in C language, and the proper name must be used? (cannot add struct when using alias)
- 员工薪资管理系统
- Intelligent computing system 1 environment construction
- Demo of integrated development of intelligent computing system 3 plugin
- JVM memory structure
猜你喜欢

Why is it not enough to declare the structure alias when using the structure variable of other files in C language, and the proper name must be used? (cannot add struct when using alias)

Markdown mermaid種草(1)_ mermaid簡介

Rsync remote synchronization

C # connect to the database to complete the operation of adding, deleting, modifying and querying

数论 --- 欧拉函数、筛法求欧拉函数、欧拉定理、费马小定理详细证明

On the first anniversary of the data security law, which four major changes are coming?

还在付费下论文吗?快来跟我一起白piao知网

2022 welder (elementary) special operation certificate examination question bank and answers

Gaozelong, a digital economy expert: Yingke changed its name to yingcosmos. Will yuancosmos become the next growth engine of Yingke?

Demo of integrated development of intelligent computing system 3 plugin
随机推荐
UESTC (shenhengtao team) & JD AI (Mei Tao team) proposed a structured dual stream attention network for video Q & A, with performance SOTA! Better than the method based on dual video representation
2788.Cifera
Kaggle肠胃道图像分割比赛baseline
2837. The total number of teams
如何获取飞机穿过雷达两端的坐标
1002_ twenty million one hundred and eighty-one thousand and nineteen
Past blue bridge cup test questions ants catch cold
2022年P气瓶充装考试练习题及在线模拟考试
On the first anniversary of the data security law, which four major changes are coming?
员工薪资管理系统
Markdown Mermaid planting grass (1)_ Introduction to Mermaid
head、tail查看文件
Jenkins pipeline's handling of job parameters
数据资产为王,如何解析企业数字化转型与数据资产管理的关系?
Pyinstaller打包pikepdf失败的问题排查
2022茶艺师(中级)考试模拟100题及模拟考试
Ali open source (easyexcel)
严重性 代码 说明 项目 文件 行 禁止显示状态 错误 LNK2038 检测到“RuntimeLibrary”的不匹配项: 值“MD_DynamicRelease”不匹配值“MDd_DynamicDe
C # application interface development foundation - form control
How does redis implement inventory deduction? How to prevent oversold?