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都可以。
到此这篇关于mybatis-plus与mybatis共存的实现的文章就介绍到这了,更多相关mybatis-plus与mybatis共存内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
使用Spring boot + jQuery上传文件(kotlin)功能实例详解
本文通过实例代码给大家介绍了使用Spring boot + jQuery上传文件(kotlin) 功能,需要的朋友可以参考下2017-07-07注解、原生Spring、SchemaBased三种方式实现AOP代码案例
这篇文章主要介绍了注解、原生Spring、SchemaBased三种方式实现AOP的方法介绍,文中有详细的代码示例,对我们的学习有一定的帮助,需要的朋友可以参考下2023-06-06Mybatis的mapper.xml中if标签test判断的用法说明
这篇文章主要介绍了Mybatis的mapper.xml中if标签test判断的用法说明,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2022-06-06synchronized及JUC显式locks 使用原理解析
这篇文章主要为大家介绍了synchronized及JUC显式locks 使用原理解析,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-12-12
最新评论