Issue
I have a spring boot project (2.7) and I'm using Java 17 and I'm using this maven package for Mybatis : mybatis-spring-boot-starter:2.2.2. And I'm using postgres 14 as my database.
In the logs I enabled Mybatis query logs, but unfortunately still I don't see logs of transactions. I want to see which queries are part of which transactions.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>demo</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
and this is my application properties file :
mybatis.typeAliasesPackage=com.example.demo.dto
mybatis.config-location=classpath:mybatis-config.xml
logging.level.org.springframework=WARN
logging.level.com.example.demo.dao.UserMapper=DEBUG
logging.level.com.example.demo.dao.TransactionMapper=DEBUG
spring.datasource.url=jdbc:postgresql://localhost:5432/user
spring.datasource.username=user
spring.datasource.password=password
and here is my mybatis config file:
<?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="mapUnderscoreToCamelCase" value="true"/>
<setting name="cacheEnabled" value="false"/>
<setting name="localCacheScope" value="STATEMENT"/>
</settings>
<typeAliases>
<package name="com.example.demo.dto" />
</typeAliases>
<mappers>
<mapper resource="mapper/UserMapper.xml"/>
<mapper resource="mapper/TransactionMapper.xml"/>
</mappers>
</configuration>
Solution
I found the answer, as it was mentioned in the comment I should have added this in the application.properties:
logging.level.org.springframework.jdbc=DEBUG
Answered By - Majid Abdolhosseini
Answer Checked By - Mildred Charles (JavaFixing Admin)