mybatis-plus与mybatis共存问题

接手了一个开发任务,在一个springboot+mybatis+nacos的框架上增加功能模块。但笔者更喜欢mybatisplus的高效率和快捷,用mapper就能实现绝大多数CURD功能(批量插入,批量删除等需要service层的支持),避免配置xml的繁琐,故决定整合mybatisplus与mybatis。
经过一番挑战后,总结如下:
一 在pom文件中添加mybatis-plus-boot-starter。
情况1:父pom中使用的是< dependencyManagement >…< /dependencyManagement >方式

-父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>

情况2 :父pom中使用的是 < dependencies >…< /dependencies > 方式

父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包,子目录无需配置。

二 配置yml文件
将原来的配置mybatis改为mybatis-plus,如图:
原来:
在这里插入图片描述

新:
在这里插入图片描述

注意:
1 mybatis单一环境,yml中配置为mybatis。
2 mybatisplus单一环境,yml中配置为mybatis-plus或mybatis都可以。

猜你喜欢

转载自blog.csdn.net/helloworldchina/article/details/121278896