springmvc+mybatis无法输出sql

xiaoyueD2009 发布于 2016/01/11 17:44
阅读 1K+
收藏 0

tomcat7.0一启动后台就标识找不到log4j配置文件,但是上一行明明已经加载进去了!?

这是web.xml,配置


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>report</display-name>
  
  <context-param>  
	    <param-name>log4jConfigLocation</param-name>  
	    <param-value>classpath:com/isoftstone/conf/log4j.properties</param-value> 
  </context-param>  
  
  <listener>  
	    <listener-class>  
	        org.springframework.web.util.Log4jConfigListener  
	    </listener-class>  
  </listener> 
  
  <!-- Spring和mybatis的配置文件 -->
  <!-- Spring应用上下文, 理解层次化的ApplicationContext -->
  <context-param>
 		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:com/isoftstone/conf/applicationContext*.xml</param-value>
  </context-param>
  
  <!-- spring security -->
  <filter>  
    	<filter-name>springSecurityFilterChain</filter-name>  
    	<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>  
  </filter>  
  <filter-mapping>  
    	<filter-name>springSecurityFilterChain</filter-name>  
    	<url-pattern>/*</url-pattern>  
  </filter-mapping>  
  
  <!-- 用户登录成功后,记住密码 -->
  <filter>  
    	<filter-name>rememberMeFilter</filter-name>  
    	<filter-class>com.isoftstone.fwk.report.security.filter.RememberMeFilter</filter-class>  
  </filter>  
  <filter-mapping>  
    	<filter-name>rememberMeFilter</filter-name>  
    	<url-pattern>/index-new.jsp</url-pattern>  
  </filter-mapping> 
    
  <!-- 解决工程编码问题 -->
  <filter id="Filter_1441014635315">
  		<filter-name>characterEncodingFilter</filter-name>
  		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  		<init-param>
  			<param-name>encoding</param-name>
  			<param-value>UTF-8</param-value>
  		</init-param>
  </filter>
  
  <filter-mapping>
  		<filter-name>characterEncodingFilter</filter-name>
  		<url-pattern>/</url-pattern>
  </filter-mapping>
  
  <!-- 解決xss漏洞 
  <filter>
		<filter-name>xssFilter</filter-name>
		<filter-class>com.security.base.XssFilter</filter-class>
  </filter>
  <filter-mapping>
		<filter-name>xssFilter</filter-name>
		<url-pattern>/*</url-pattern>
  </filter-mapping>
  -->
	
  <!-- 配置Spring监听 -->
  <listener>
		<listener-class>
			org.springframework.web.context.ContextLoaderListener
		</listener-class>
  </listener>
  <!-- 项目启动开启任务 -->
  <listener>
		<listener-class>
			com.isoftstone.pcis.report.monitor.servlet.MyTimerListener
		</listener-class>
  </listener>
  <!-- 防止Spring内存溢出监听器 -->
  <listener>
	   <listener-class>
			org.springframework.web.util.IntrospectorCleanupListener
	   </listener-class>
  </listener>
  <!-- 监听session创建和销毁
  <listener>
		<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
  </listener>
	 -->
  <!--离线下载监听
  <listener>
		<listener-class>com.isoftstone.pcis.report.offlineDownload.OfflineDownloadListener</listener-class>
  </listener>-->
  <!-- DispatcherServlet, Spring MVC的核心 -->
  <servlet id="Servlet_1441014635237">
		<servlet-name>mvc-dispatcher</servlet-name>
		<servlet-class> org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<!-- DispatcherServlet对应的上下文配置, 默认为/WEB-INF/$servlet-name$-servlet.xml
		 -->
		<init-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>classpath:com/isoftstone/conf/mvc-dispatcher-servlet.xml</param-value>
        </init-param>
		<load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping id="ServletMapping_1441014635100">
		<servlet-name>mvc-dispatcher</servlet-name>
	    <!-- mvc-dispatcher拦截所有的请求-->
		<url-pattern>/</url-pattern>
  </servlet-mapping>
  
  <jsp-config>
	  <taglib>
	    <taglib-uri>/datatables</taglib-uri>
	    <taglib-location>/WEB-INF/tlds/datatables.tld</taglib-location>
	  </taglib>
  </jsp-config>
  
	<welcome-file-list>
		<welcome-file>index-new.jsp</welcome-file>
	</welcome-file-list>
</web-app>



这是我的log4j配置文件
#\u5B9A\u4E49LOG\u8F93\u51FA\u7EA7\u522B
log4j.rootLogger=debug
#\u5B9A\u4E49\u65E5\u5FD7\u8F93\u51FA\u76EE\u7684\u5730\u4E3A\u63A7\u5236\u53F0
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
#\u53EF\u4EE5\u7075\u6D3B\u5730\u6307\u5B9A\u65E5\u5FD7\u8F93\u51FA\u683C\u5F0F\uFF0C\u4E0B\u9762\u4E00\u884C\u662F\u6307\u5B9A\u5177\u4F53\u7684\u683C\u5F0F
log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n

#\u6587\u4EF6\u5927\u5C0F\u5230\u8FBE\u6307\u5B9A\u5C3A\u5BF8\u7684\u65F6\u5019\u4EA7\u751F\u4E00\u4E2A\u65B0\u7684\u6587\u4EF6
log4j.appender.File = org.apache.log4j.RollingFileAppender
#\u6307\u5B9A\u8F93\u51FA\u76EE\u5F55
log4j.appender.File.File = logs/ssm.log
#\u5B9A\u4E49\u6587\u4EF6\u6700\u5927\u5927\u5C0F
log4j.appender.File.MaxFileSize = 10MB
# \u8F93\u51FA\u6240\u4EE5\u65E5\u5FD7\uFF0C\u5982\u679C\u6362\u6210DEBUG\u8868\u793A\u8F93\u51FADEBUG\u4EE5\u4E0A\u7EA7\u522B\u65E5\u5FD7
log4j.appender.File.Threshold = ALL
log4j.appender.File.layout = org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n

###\u663E\u793ASQL\u8BED\u53E5\u90E8\u5206
log4j.logger.com.ibatis=DEBUG 
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG 
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG 
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG 
log4j.logger.java.sql.Connection=DEBUG 
log4j.logger.java.sql.Statement=DEBUG 
log4j.logger.java.sql.PreparedStatement=DEBUG

maven包的引入


<!-- log4j日志文件管理包版本 -->
    <slf4j.version>1.6.6</slf4j.version>
    <log4j.version>1.2.17</log4j.version>
     
<!-- 日志文件管理包 -->
     <!-- log start -->
     <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <version>${log4j.version}</version>
     </dependency>      
     <!-- 格式化对象,方便输出日志 -->
     <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <version>${slf4j.version}</version>
     </dependency>

     <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-log4j12</artifactId>
         <version>${slf4j.version}</version>
     </dependency>
     <!-- log end -->



<!-- spring版本号 -->
    <spring.version>4.2.0.RELEASE</spring.version>
    <security.version>3.1.0.RELEASE</security.version>
    <!-- mybatis版本号 -->
    <mybatis.version>3.2.8</mybatis.version>




加载中
0
LucEsape
LucEsape
log4j.logger.你的dao层包名=DEBUG
xiaoyueD2009
xiaoyueD2009
回复 @老鱼的饵 : 已经在class目录下呢,不能classpath*,只能这么加载classpath
LucEsape
LucEsape
回复 @xiaoyueD2009 : 你把你的log4j配置文件放到 /WEB-INF/classes/ 下,参数改为 classpath*:log4j.properties,试试
xiaoyueD2009
xiaoyueD2009
回复 @老鱼的饵 : 以图1为准,图2是我后来调整到classpath路径调试,两个都不行,我编译一下
LucEsape
LucEsape
回复 @xiaoyueD2009 : 图1中 2个配置文件的路径都不一样。你加载的是哪个呢
xiaoyueD2009
xiaoyueD2009
回复 @老鱼的饵 : classpath:com/isoftstone/conf/log4j.properties路径写法用的是这个,加个*反而不识别!最奇怪的是明明显示初始化成功了Initializing log4j from [classpath:com/isoftstone/conf/log4j.properties],但是到spring加载的时候就是找不到文件
下一页
返回顶部
顶部