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

本文主要记录在本机启动调试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工程的版本号,如图所示:

【源码Mybatis系列】——Mybatis源码本地打包编译_第1张图片

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


    org.mybatis
    mybatis-parent
    31
    ../parent/pom.xml
  

 解决mybatis编译不成功

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

检查idea的jdk版本

【源码Mybatis系列】——Mybatis源码本地打包编译_第2张图片

【源码Mybatis系列】——Mybatis源码本地打包编译_第3张图片 

【源码Mybatis系列】——Mybatis源码本地打包编译_第4张图片

【源码Mybatis系列】——Mybatis源码本地打包编译_第5张图片 

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

mac配置jdk环境,参考文章:https://blog.csdn.net/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中添加插件


    org.apache.maven.plugins
    maven-surefire-plugin
    
        true
    

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

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

你可能感兴趣的:(【源码Mybatis系列】)