Mybatis-plus and mybatis coexistence problem

I took over a development task to add functional modules to a springboot+mybatis+nacos framework. But the author prefers the high efficiency and speed of mybatisplus. Most of the CURD functions (batch insertion, batch deletion, etc. need the support of the service layer) can be realized with mapper, and avoid the cumbersome configuration of xml, so I decided to integrate mybatisplus and mybatis.
After some challenges, the summary is as follows:
1. Add mybatis-plus-boot-starter to the pom file.
Case 1 : < dependencyManagement >…</dependencyManagement> is used in the parent pom

-父pom配置:

<!-- 依赖声明 -->
   <dependencyManagement>
     <dependencies>
		
		<!--mybatis-plus 依赖配置-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.3</version>
        </dependency>
     </dependencies>
  </dependencyManagement>
-子pom配置:

<!--mybatis-plus 依赖配置-->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>

Case 2: The parent pom uses the < dependencies >... < /dependencies > method

父pom配置:
   <!--mybatis-plus 依赖配置-->
<dependencies>
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.4.3</version>
</dependency>
</dependencies>
子pom配置:
子pom会自动使用父pom中的jar包,子目录无需配置。

2. Configure the yml file
Change the original configuration mybatis to mybatis-plus, as shown in the figure:
original:
insert image description here

new:
insert image description here

Note:
1 mybatis single environment, configured as mybatis in yml.
2 mybatisplus single environment, yml can be configured as mybatis-plus or mybatis.

Guess you like

Origin blog.csdn.net/helloworldchina/article/details/121278896