在java web项目中我们通常会有这样的需求:当项目启动时执行一些初始化操作,例如从数据库加载全局配置文件等,通常情况下我们会用javaee规范中的Listener去实现

常用的监听器有spring的ContextLoaderListener  或者logback

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/spring-application.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>  
    <listener-class>ch.qos.logback.ext.spring.web.LogbackConfigListener</listener-class>  
</listener>  
<context-param>  
    <param-name>logbackConfigLocation</param-name>  
    <param-value>classpath:logback.xml</param-value>  
</context-param>  

 

相关文章:

  • 2021-10-24
  • 2021-07-19
  • 2021-05-16
  • 2021-09-28
  • 2021-06-23
  • 2021-12-21
  • 2021-06-23
  • 2021-10-31
猜你喜欢
  • 2021-09-26
  • 2021-11-15
  • 2020-02-20
  • 2022-02-03
  • 2021-12-21
  • 2022-12-23
  • 2021-07-25
相关资源
相似解决方案