参考这个: http://www.cnblogs.com/yjmyzz/p/4033729.html (0)spring的配置里,指出mybatis-config.xml的路径。
<beans:bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <beans:property name="dataSource" ref="dataSource" /> <beans:property name="configLocation" value="/WEB-INF/mybatis-config.xml" /> </beans:bean>
(1)在mybatis-config.xml里要设置用Log4j打印
<?xml version="1.0" encoding="UTF-8" ?> 2 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" 3 "http://mybatis.org/dtd/mybatis-3-config.dtd"> 4 <configuration> 5 <settings> 6 <setting name="logImpl" value="LOG4J" /> 7 </settings> 8 </configuration>
(2)在log4j.properties里加一行 log4j.logger.com.xxx.yyy.dao=DEBUG 就是你的xxxMapper所在的包名,这样调用时就会打印sql及参数了。
|