首页 课程 师资 教程 报名

MyBatis源码下载编译

  • 2022-12-05 10:42:36
  • 1186次 星辉

相信大家对什么是Mybatis已经有所了解,下面我们来了解一下MyBatis源码下载编译。

1.下载mybatis源码

官网地址:https://github.com/mybatis/mybatis-3

选择需要的版本下载。

本例下载的是 mybatis-3-mybatis-3.5.1,下载完后解压。打开pom.xml,查看mybatis的依赖的父工程版本

2.下载载mybatis-parent源码

选择mybatis对应的mybatis-parent版本,本例版本是 mybatis-parent-31

3.源码导入Idea

在Idea中新建一个空项目,将 mybatis 、 mybatis-parent 都放到空项目下,并导入模块

4.编译mybatis-parent源码,编译mybatis源码

(1)编译mybatis-parent项目

切换mybatis-parent项目:

命令:mvn clean install

(2)编译mybatis项目

切换mybatis-parent项目:

命令:mvn install -Dmaven.test.skip=true

注意:可能pdf报错

Failed to execute goal org.apache.maven.plugins:maven-pdf-plugin:1.4:pdf (pdf) on project mybatis: Error during document generation: Error parsing /Users/h__d/Documents/workspace-idea/mybatis-3.5.1/mybatis-3-mybatis-3.5.1/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)

解决:将maven-pdf-plugin插件注释,再次进行编译安装

<!--<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pdf-plugin</artifactId>
</plugin>-->

5.测试使用源码

(1)修改mybatis版本(3.5.1-MY),重新编译。避免与官网依赖相同版本

(2)新建maven模块项目test-mybatis-my

(3)使用测试

注意:可能报错,如下:

解决:引入依赖

<dependency>
    <groupId>ognl</groupId>
    <artifactId>ognl</artifactId>
    <version>3.2.15</version>
    <scope>compile</scope>
    <optional>true</optional></dependency><dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.27.0-GA</version>
    <scope>compile</scope>
    <optional>true</optional></dependency>

之后便能正常测试完成,使用mybatis查出数据。想了解更多可查看Mybatis视频教程。星辉星辉在线学习教程,针对没有任何Java基础的读者学习,让你从入门到精通,主要介绍了一些Java基础的核心知识,让同学们更好更方便的学习和了解Java编程,感兴趣的同学可以关注一下。 

选你想看

你适合学Java吗?4大专业测评方法

代码逻辑 吸收能力 技术学习能力 综合素质

先测评确定适合在学习

在线申请免费测试名额
价值1998元实验班免费学
姓名
手机
提交