【源码Mybatis系列】——Mybatis源码本地打包编译

本文详述在本地环境中编译Mybatis源码的步骤与常见问题解决,包括处理parent依赖、IDEA JDK版本冲突及单元测试失败等,助你顺利开启Mybatis源码学习之旅。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文主要记录在本机启动调试Mybatis源码中,本机基于Mybatis master 分支本地打包遇到问题整理。

https://github.com/mybatis/mybatis-3

https://github.com/mybatis/parent(依赖)

Mybatis源码依赖于parent工程。需要先编译parent工程在编译mybatis,具体如下

解决parent依赖问题

在构建的过程中会出现找不到pom.xml中依赖的父模块mybatis-parent

我们需要将paren工程克隆到本地目录中:git clone https://github.com/mybatis/parent.git ,然后先进入parent工程下进行mvn clean install 将parent工程依赖的包下载下来、并保证parent工程编译通过,这步不会出现问题,在编译的输出信息中我们会看到parent工程的版本号,如图所示:

pom.xml文件parent依赖的version标签处,如下文。 
接下来修改mybatis工程的pom.xml文件中标识parent依赖的地方:

<parent>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-parent</artifactId>
    <version>31</version>
    <relativePath>../parent/pom.xml</relativePath>
  </parent>

 解决mybatis编译不成功

1、解决Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile

检查idea的jdk版本

 

 

如果idea版本设置都一致了,但是编译依旧报错,检查本机环境变量以及maven和idea的jdk版本是否一致,将三者设置一致

mac配置jdk环境,参考文章:https://blog.youkuaiyun.com/transformed/article/details/82316815

2、maven编译报错:java.lang.ExceptionInInitializerError: com.sun.tools.javac.code.TypeTags

jdk版本太高,原因是lombok版本太低,不支持java10以上。

3、Please refer to xxx/xxxx/mybatis/target/surefire-reports for the individual test results

\target\surefire-reports for the individual test results,无法正常打包,原因为单元测试不通过,maven打包就停止编译

pom.xml中添加插件

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <testFailureIgnore>true</testFailureIgnore>
    </configuration>
</plugin>

解决完上述问题,终于编译成功,开启Mybatis的源码之路!

祝每位遇到问题寻求解决的朋友,始终目标坚定,砥砺前行,一直奋斗在路上!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Mandy_i

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值