首页 > 其他 > 详细

【Mybatis3源码学习之一】搭建Mybatis3源码环境

时间:2020-05-07 22:48:30      阅读:236      评论:0      收藏:0      [点我收藏+]

版本
  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:\srcs\mybatis-3-mybatis-3.5.4\target\pdf\site.tmp\xdoc\getting-started.xml: Error parsing the model: only whitespace content allowed before start tag and not \ufeff (position: COMMENT seen ...rning permissions and\n       limitations under the License.\n\n-->\n\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>

参考:

源码地址
mybatis3.x官方手册
Mybatis3源码深度解析
mybatis 3.x源码深度解析与最佳实践

【Mybatis3源码学习之一】搭建Mybatis3源码环境

原文:https://www.cnblogs.com/cac2020/p/12845608.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!