SpringMVC-servlet.xml
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:mybatis-config.xml"></property> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:net/fundway/gzga/mapping/*.xml"></property> </bean>
mybatis-config.xml:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <settings> <!-- 打印查询语句 --> <setting name="logImpl" value="STDOUT_LOGGING" /> </settings> </configuration>
参考 http://www.mybatis.org/mybatis-3/zh/configuration.html#settings
控制台打印:
==> Preparing: SELECT * FROM t_win WHERE activityId = ? AND batch = ?; ==> Parameters: 37(Integer), 4(Integer)