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

╄→гoц情女王★ 提交于 2020-08-05 13:33:22

本文主要记录在本机启动调试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.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中添加插件

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

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!