问题
想要查看mybatis中xml内的sql执行过程中语句是什么样的,(查看sql日志)
一种解决办法
- 首先,所在项目的pom.xml文件中
dependencies
中添加如下 springboot的日志依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
</dependencies>
- 找到application.yml文件
添加下边代码
mybatis: #mybatis映射文件通配
mapper-locations: classpath:*Mapper.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
classpath:
后边跟的就是想要打印日志的mapper.xml,上述代码将会打印所有以Mapper.xml结尾文件的运行日志。
- 试试应该就行了吧