`

spring的contextinitialized 执行了2次

 
阅读更多

今天遇见了个很神奇的问题;本来想spring启动的时候,启动一个监听,执行一段代码;

后来发现一直执行了2次;本来以为是tomcat执行了一次,spring执行了一次;后来发现不是;原来

 

 <listener>
  <listener-class>com.hh.listener.DxmListener</listener-class>
 </listener>
   
    <listener>
  <listener-class>com.hh.listener.DxmListener</listener-class>
 </listener>

 

自己写了2次;。。。无语

 

分享到:
评论

相关推荐

    Struts2+Spring3+MyBatis3完整实例

    网上的东西好大多都不能直接用,自己结合网上资料做了一个Struts2+Spring3+MyBatis3的测试工程,JUnit测试用例和WEB服务。 内涵完整jar包,解压直接可用,包括一个表文件。 Eclipse3.2+Tomcat/5.5+jdk1.5.0_17 - ...

    tomcat启动|退出执行事件

    tomcat启动|退出执行事件类: import java.io.File; import java.io.FileWriter; import java.io.... public void contextInitialized(ServletContextEvent sce) { WriteFile();// 添加一个新的文本文件 }

    spring的监听器和缓存.docx

    public void contextInitialized(ServletContextEvent sce) { log.info("web项目的启动{} 一开始就启动",sce.getServletContext()); System.err.println("web项目的启动{}"); } ​ @Override public ...

    Spring.net框架

    (2)接口依赖; (3)基 于配置文件和Reflection的工厂模式; (4)使用Spring.net实现Ioc; (5)Romoting; (6)利用Ioc在不动一行代码的情 况下实现Remoting。为了更好的理解文中的内容,最好顺序阅读。 作为一...

    springframework.5.0.12.RELEASE

    Exporting a lazily initialized bean (which implements SelfNaming and is annotated with ManagedResource annotation) gives IllegalStateException [SPR-17592] #22124 MockHttpServletRequest changes Accept-...

    spring-framework-reference-4.1.2

    Not Using Commons Logging ..........................Lazy-initialized beans ....................................................................................... 47 Autowiring collaborators ...............

    servlet小型项目

    public void contextInitialized(ServletContextEvent event) { Map map = new TreeMap(); Book b1 = new Book(1,"core java",100); Book b2 = new Book(2,"c++",132); Book b3 = new Book(3,"php",10); ...

    struts2驱动包

    严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error ...

    SpringBoot整合Listener的两种方式.docx

    SpringBoot整合Listener的两种方式: ...1.创建一个类实现 ServletContextListener (具体实现哪个...3.重写 contextInitialized() 与 contextDestroyed() 方法 4.编写启动类 5.增加注解 @ServletComponentScan

    com.springsource.org.objectweb.asm-3.2.0.jar

    严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error ...

    光盘刻录大师crt not initialized修复文件

    完美修复光盘刻录大师报crt not initialized的错误 使用方法:将文件覆盖到安装目录即可 解压密码:17

    spring-boot-db-initialization-test:测试用例,显示未初始化数据库以进行测试的错误

    Could not send event to complete DataSource initialization (ApplicationEventMulticaster not initialized - call ' refresh ' before multicasting events via the context: org.springframework.web.context....

    ssmDemo1:SSM框架整合练习项目 来自《2017-7黑马49期web》

    严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error ...

    Spring.Boot.in.Action.2015.12.pdf

    Examining a newly initialized spring boot project 26 Dissecting Bc iect build 30 2.2 USing starter dependencies 33 Specifying facet-based dependencies 34. Overriding starter transitive dependencies 35...

    Spring3mvcxml:具有XML配置的旧版Spring3mvc

    Spring3mvcxml Spring3mvcxml 具有XML配置的旧版Spring3mvc。 码头准备就绪并启用。 制作说明 git clone https://github.com/gencube/Spring3mvcxml.git cd Spring3mvcxml mvn clean package 运行服务 # with run...

    spring-framework-reference4.1.4

    Not Using Commons Logging ..........................Lazy-initialized beans ....................................................................................... 47 Autowiring collaborators ...............

    Struts2中实现web应用的初始化实例详解

    其中一种比较好的方式,是通过实现ServletContextListener接口进行坚挺,重写contextInitialized方法,实现自己需要进行的初始化操作,之后在web.xml中添加相应的listner,tomcat在启动服务时会调用相应方法。...

    低清版 大型门户网站是这样炼成的.pdf

    (Struts 2+Spring 2+Hibernate 3).pdf(完整版) 网上有高清版350M的。可以去下 http://115.com/file/be5gwid8 请于下载后 24H 内及时删除!请抱着学习的态度下载此资料。 总共900多页!!!!!!! 第1篇 ...

    如何在Web应用中去启动后台的任务

    本方案的原理是写一个实现了ServletContextListener接口的类,该类中有两个方法:public void contextInitialized,它是在应用启动时调用;另一个方法是:public void contextDestroyed,该方法是在应用结束时调用。

    geekbanglessons:怪胎课程

    怪胎课程 极客课后作业 01周 1,通过maven tomcat启动 2, 进入注册页面登录...3,com.cdd.user.web.web.listener.DBConnectionInitializerListener#contextInitialized可以读取jndi数据源如果没有则获取固定的数据源...

Global site tag (gtag.js) - Google Analytics