Ask Your Question
1

Why does Spring Boot invariably invoke the Hibernate package and cause an error while attempting to utilize MyBatis?

asked 2023-05-03 07:08:50 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-05-03 07:32:01 +0000

nofretete gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-03 07:08:50 +0000

Seen: 11 times

Last updated: May 03 '23