Mybatis-Plus 整合集成

发布于
Mybatis-Plus 整合集成

上小节中,我们已经快速快速入门了 Mybatis-Plus ,但是使用的示例项目是 Spring Boot,考虑有些小伙伴使用的是 Spring MVC,本文将两种框架的整合方式单独挑出来讲一下。

一、Spring Boot

Maven:

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>版本号</version>
</dependency>

Gradle:

compile group: 'com.baomidou', name: 'mybatis-plus-boot-starter', version: '版本号'

TIP : 版本号可以进 Maven 中央仓库 输入关键字查看,个人推荐是,挑一个比较新的版本,且使用人数比较多的,这种相对来说比较稳定,如下图:

二、Spring MVC

Maven:

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus</artifactId>
    <version>版本号</version>
</dependency>

Gradle:

compile group: 'com.baomidou', name: 'mybatis-plus', version: '版本号'

注意:

引入 MyBatis-Plus 之后请不要再次引入 MyBatis 以及 MyBatis-Spring,以避免因版本差异导致的问题。

13:T19d6,

上小节中,我们已经快速快速入门了 Mybatis-Plus ,但是使用的示例项目是 Spring Boot,考虑有些小伙伴使用的是 Spring MVC,本文将两种框架的整合方式单独挑出来讲一下。

一、Spring Boot

Maven:

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>版本号</version></dependency>

Gradle:

compile group: 'com.baomidou', name: 'mybatis-plus-boot-starter', version: '版本号'

TIP : 版本号可以进 Maven 中央仓库 输入关键字查看,个人推荐是,挑一个比较新的版本,且使用人数比较多的,这种相对来说比较稳定,如下图:

二、Spring MVC

Maven:

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus</artifactId>
    <version>版本号</version></dependency>

Gradle:

compile group: 'com.baomidou', name: 'mybatis-plus', version: '版本号'

注意:

引入 MyBatis-Plus 之后请不要再次引入 MyBatis 以及 MyBatis-Spring,以避免因版本差异导致的问题。