`

Spring监听器配置

    博客分类:
  • Java
阅读更多

使用spring框架时如果同时使用org.springframework.web.util.Log4jConfigListener监听器,那么在web.xml中的监听器的注册顺序为org.springframework.web.context.ContextLoaderListener在后,org.springframework.web.util.Log4jConfigListener在前,否则就回出现如下警告:

log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.

我们在spring的api文档中可以看到下面一段说明:

Bootstrap listener to start up Spring's root WebApplicationContext. Simply delegates to ContextLoader.

This listener should be registered after Log4jConfigListener in web.xml, if the latter is used.

 

正确配置如下:

<listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

 

1
2
分享到:
评论

相关推荐

    Web项目中使用Spring, 使用 Spring 的器监听器 ContextLoaderListener.docx

    二、 使用 Spring 的器监听器 ContextLoaderListener o1. maven依赖pom.xml o2. 注册监听器 ContextLoaderListener o3. 指定 Spring 配置文件的位置 o4. 获取Spring容器对象 在 Web 项目中使用 Spring 框架,首先...

    监听器获取Spring配置文件的方法

    主要为大家详细介绍了监听器获取Spring配置文件的方法,很实用的方法,感兴趣的小伙伴们可以参考一下

    Spring Cloud Bus配合Spring Cloud Config使用可以实现配置的动态刷新(2.自动动态刷新).zip

    Bus支持两种消息代理:RabbitMQ...spring cloud bus在整个后端服务中起到联通的作用,比如我们需要更新整体配置,只需在git上发布新版本,并对修改点服务端发送命令,bus在监听的情况下会对所有关联的客户端更新消息。

    spring框架技术+第2天+xmind思维导图

    spring框架技术+第2天+xmind思维导图:生命周期,介绍simple project,打印出构造方法...bean作用域request session globalSession:web项目获取核心配置文件要配置两个地方:spring监听器、spring作用域范围的监听。

    从零开始学Spring Boot

    1.24 Spring Boot过滤器、监听器 1.25 Spring Boot 拦截器HandlerInterceptor 1.26 Spring Boot启动加载数据CommandLineRunner 1.27 Spring Boot环境变量读取和属性对象的绑定 1.28 Spring Boot使用自定义的...

    自定义PROXOOL监听器整合SSH框架

    1、proxool官网,下载最新的proxool-0.9.1.jar 2、创建独立的proxool.xml文件,同时存在Web的WEB-INF目录下,根据自己的数据库类型,填写...5、整合Spring和proxool,配置应用上下文配置文件[applicationContext.xml]

    struts2+spring+hibernate整合示例

    web容器中(web.xml)中添加struts2 filter以及spring 监听器。 b 在struts.xml中添加action,使用通配符的方式 , 注意这里和单独struts2不同的地方: class属性指向的是bean 的 id ,这里我们配置bean采用spring ...

    Spring-Reference_zh_CN(Spring中文参考手册)

    6.8.3. 使用Spring IoC来配置AspectJ的切面 6.8.4. 在Spring应用中使用AspectJ Load-time weaving(LTW) 6.9. 其它资源 7. Spring AOP APIs 7.1. 简介 7.2. Spring中的切入点API 7.2.1. 概念 7.2.2. 切入点实施 ...

    Spring 2.0 开发参考手册

    6.8.3. 使用Spring IoC来配置AspectJ的切面 6.8.4. 在Spring应用中使用AspectJ Load-time weaving(LTW) 6.9. 其它资源 7. Spring AOP APIs 7.1. 简介 7.2. Spring中的切入点API 7.2.1. 概念 7.2.2. 切入点...

    spring-mvc代码示例+注释+文件解析(可直接运行)

    1、web.xml这个中间要加入spring-mvc的配置文件的加载路径,以及相关的监听器,具体看注释。 2、spring-mvc配置文件包括两部分,一个是spring传统配置文件,在代码中为“applicationContext.xml”,主要配置代码中...

    spring+shiro+ehcache例子

    在web.xml中配置spring容器的监听器。 2:项目集成springmvc 在web.xml中配置前端控制器 3:项目集成shiro 在web.xml中配置shiro过滤器 4:项目post乱码处理 在web.xml中配置字符过滤器 5:项目运行...

    Spring中文帮助文档

    13.12. 基于注解的控制器配置 13.12.1. 建立dispatcher实现注解支持 13.12.2. 使用@Controller定义一个控制器 13.12.3. 使用@RequestMapping映射请求 13.12.4. 使用@RequestParam绑定请求参数到方法参数 13.12....

    Spring.3.x企业应用开发实战(完整版).part2

    12.2.4 添加Hibernate事件监听器 12.2.5 使用原生Hibernate API 12.2.6 使用注解配置 12.2.7 事务处理 12.2.8 延迟加载的问题 12.3 在Spring中使用myBatis 12.3.1 配置SqlMapClient 12.3.2 在Spring配置myBatis ...

    Spring API

    13.12. 基于注解的控制器配置 13.12.1. 建立dispatcher实现注解支持 13.12.2. 使用@Controller定义一个控制器 13.12.3. 使用@RequestMapping映射请求 13.12.4. 使用@RequestParam绑定请求参数到方法参数 13.12....

    spring chm文档

    6.8.3. 使用Spring IoC来配置AspectJ的切面 6.8.4. 在Spring应用中使用AspectJ Load-time weaving(LTW) 6.9. 其它资源 7. Spring AOP APIs 7.1. 简介 7.2. Spring中的切入点API 7.2.1. 概念 7.2.2. 切入点...

    springweb3.0MVC注解(附实例)

    -- Spring 容器启动监听器 --&gt; org.springframework.web.context.ContextLoaderListener &lt;/listener&gt; &lt;!-- Spring MVC 的Servlet,它将加载WEB-INF/annomvc-servlet.xml 的 配置文件, 以启动Spring MVC...

    Spring Boot中文文档.rar

    28.4.1.Servlet,过滤器和监听器 注册Servlet,过滤器和监听器Spring Beans 28.4.2.Servlet上下文初始化 扫描Servlet,过滤器和侦听器 28.4.3.ServletWebServerApplicationContext 28.4.4.自定义...

    整合struts2和spring源代码(可以直接在tomcat中运行)

    3.配置spring的监听器: 在web.xml中添加 org.springframework.web.context.ContextLoaderListener 4.配置spring的配置文件(可以查看WEB-INF里面的applicationContext.xml文件) 注意:如果是默认...

    java解决org.springframework.web.context.ContextLoaderListener

    java解决org.springframework.web.context.ContextLoaderListener

    Struts2框架整合Spring整合步骤

    1.新建工程,加入所需要的包; 2.配置sturts.xml; 3.配置Spring监听器; 4.Spring配置文件; .......

Global site tag (gtag.js) - Google Analytics