您的位置:首页 > 编程语言 > Java开发

编译mybatis 3.4.6 替换到springboot 2.0.2

2018-08-01 15:53 633 查看
编译mybatis需要先编译一个mybatis的parent项目(对应的spring boot 2.0.2的mybatis-spring-boot-starter的mybatis版本)

本文举例为mybatis 3.4.6(本文当前的springboot 依赖3.4.6 可以在idea安装插件maven helper查看到)

查看pom发现 3.4.6需要parent的29 所以git下载后直接切换到tag 29先编译parent

编译完成后自动就安装到本地了 接下来直接编译mybatis就行了

#新建一个目录
git clone https://github.com/mybatis/parent.git cd parent
git checkout mybatis-parent-29
# 先编译parent  直接mvn install 就会安装到本地库中
mvn install
cd ..
git clone https://github.com/mybatis/mybatis-3.git cd mybatis-3
git checkout mybatis-3.4.6
cd ..
# 再切换到 mybatis目录中
mvn clean
mvn install -DskipTests=true -Dmaven.test.skip=true -Dlicense.skip=true

# 修改 mybatis的 pom.xml 增加一个-snapshot 就可以在本地生成自己的mybatis 3.4.6-snapshot的jar包
# <artifactId>mybatis</artifactId>
#  <version>3.4.6-snapshot</version>
#  <packaging>jar</packaging>

然后如下修改springboot的pom.xml文件 就能使用自己的mybatis了

这里要注意 编译生成的jar包最好改个名字不要和原版的一样方便区分和调试

<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6-snapshot</version>
</dependency>

然后修改springboot的pom后 使用以上代码 排除原版的mybatis的jar包 换上我们自己的snapshot 的 jar就行了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息