版本
jdk1.8.0_171
Mybatis-3.5.4
IDE:Eclipse
1、下载代码
源码在github上,需要下载三个代码:
mybatis-parent Mybatis父依赖
mybatis Mybatis源码
mybatis-spring Mybatis和Spring集成

将三个项目分别导入:File-->Import-->Maven-->Existing Maven Projects

2、修改parent父依赖路径
mybatis和mybatis-spring依赖parent,修改mybatis/pom.xml和mybatis-spring/pom.xml
<parent>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-parent</artifactId>
<version>31</version>
<relativePath>../mybatis-parent/pom.xml</relativePath>
</parent>
3、构建
选中各个项目中的pom.xml,右键选择Run as --> Run Configrations...
Goals输入: clean install -Dmaven.test.skip

mybatis构建BUILD FAILURE:
[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 25.357 s [INFO] Finished at: 2020-05-07T17:41:33+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-pdf-plugin:1.4:pdf (pdf) on project mybatis: Error during document generation: Error parsing E:srcsmybatis-3-mybatis-3.5.4 argetpdfsite.tmpxdocgetting-started.xml: Error parsing the model: only whitespace content allowed before start tag and not ufeff (position: COMMENT seen ...rning permissions and limitations under the License. --> ufeff... @18:2) -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
将mybatis/pom.xml以下部分注释掉
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pdf-plugin</artifactId> </plugin>
将mybatis-parent/pom.xml以下部分注释掉
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pdf-plugin</artifactId>
<version>${pdf.version}</version>
<executions>
<execution>
<id>pdf</id>
<phase>prepare-package</phase>
<goals>
<goal>pdf</goal>
</goals>
<configuration>
<includeReports>false</includeReports>
</configuration>
</execution>
</executions>
</plugin>
4、构建后测试
使用Junit测试
/mybatis/src/test/java/org/apache/ibatis/submitted/basetest/BaseTest.java
会报错:
java.lang.NoClassDefFoundError: org/junit/platform/launcher/core/LauncherFactory
参考这篇文章解决:https://blog.csdn.net/weixin_41287260/article/details/90578478
主要是缺少JUnit Platform提供了运行(测试框架)环境的平台。
在mybatis/pom.xml中
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
下面加入
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
参考: