zoukankan      html  css  js  c++  java
  • 【Mybatis3源码学习之一】搭建Mybatis3源码环境

    版本
      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>

    参考:

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

  • 相关阅读:
    java基础
    JAVASE 安装步骤
    MySQL 45道练习题
    MySQL 多表查询
    2018-08-07JDBC连接MySQL+增删改表格+SQL注入问题及其预处理对象PreparedStatement解决方案
    2018-08-06Java中的异常捕获和Throw详细细节
    2018-08-03List接口方法+LinkedList方法+Vector集合+Set接口下HashSet和LinkedHashSet集合+HashCode()+equals()方法对于Set接口判断重复的详细细节
    2018-08-01集合Collection+Iterator迭代器+泛型+增强For循环
    2018-07-31包装类与基本数据类型String的转换+System类详细知识+Arrays类+大数据(BigInteger+BigDecimal)运算
    2018-07-27Final+Static+匿名对象+3中代码块
  • 原文地址:https://www.cnblogs.com/cac2020/p/12845608.html
Copyright © 2011-2022 走看看