问题
使用mybatis的时候没有sql输出,看不到sql不方便调试
配置
- 配置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>
- 引入配置文件
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath*:mapper/**/*.xml" />
<property name="configLocation" value="classpath:mybatis-config.xml" />
</bean>
- 配置logback.xml
<logger name="org.apache.ibatis" level="DEBUG">
<appender-ref ref="Console" />
</logger>
<logger name="java.sql" level="debug">
<appender-ref ref="Console" />
</logger>
网友评论