Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Spring Boot does not invariably invoke the Hibernate package. It depends on how the application is configured. By default, Spring Boot uses Hibernate as the default ORM framework. However, if you want to use MyBatis or any other ORM framework, you need to configure it explicitly in your application.

If you are experiencing an error while attempting to utilize MyBatis, it might be due to conflicting dependencies between Hibernate and MyBatis. To resolve this issue, you can exclude the Hibernate dependencies from your project by adding the following exclusion to your pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Alternatively, you can use the mybatis-spring-boot-starter dependency, which will automatically configure MyBatis in your Spring Boot application.