MyBatis显示完整sql和参数
2019-10-14 本文已影响0人
观海飞鱼
1、在mybatis-config.xml中配置加一个setting
没有改文件可以新增一个,内容如下:
<?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>
2、在spring集成mybatis的sqlSessionFactory配置configLocation属性
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
<property name="mapperLocations" value="classpath:com/xxx/mapping/**/*Mapper.xml"></property>