IDEA 构建 mybatis 源码


mybatis 源码构建

# mybatis构建步骤
- 下载 mybatis源码 
- 解压 mybatis源码 查看mybatis-Parent版本要求
- 下载mybatis-Parent 源码
- 构建 mybatis-Parent
- 构建 mybatis源码
- IDEA 创建 Maven工程 mybatis-source
- Maven工程mybatis-source 导入mybatis源码、mybatis-parent源码

mybatis-source 下载

mybatis源码下载

通过github下载mybatis源码。

https://github.com/mybatis/mybatis-3

这里使用mybatis-3.5.0构建。

https://github.com/mybatis/mybatis-3/archive/refs/tags/mybatis-3.5.0.zip

可以通过Release找到老版本,直接下载源码Source Code到本地。

mybatis-parent 版本信息

解压mybatis 打开pom.xml配置文件,查看mybatis-parent版本信息。

  <parent>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-parent</artifactId>
    <version>31</version>
    <relativePath />
  </parent>

通过pom.xml知,下载mybatis-parent的版本为31。

mybatis-parent 下载

通过github下载mybatis-parent源码。

https://github.com/mybatis/parent

因为通过pom.xml查看到mybatis-parent的版本为31。这里选择下载31版本的parent。其它版本的mybatis源码自行通过pom.xml查看parent相关信息。

https://github.com/mybatis/parent/archive/refs/tags/mybatis-parent-31.zip

mybatis-parent 编译

- 注: 编译之前 先将maven源 更换为 aliyun的源,否则编译可能会失败。

可以通过cmd执行编译 或者 通过idea编译。这里选择通过cmd编译mybatis-parent。

mvn clean install -Dmaven.test.skip

image-20210707115728186

IDEA 创建 Maven 工程

# 前提条件- IDEA 已经配置好 MAVEN (若没有配置好,自行百度)
# IDEA配置步骤
- 创建Maven空工程
- 删除项目中src目录
- 修改`pom.xml`文件
- 复制编译好的mybatis-parent到mybatis-source中
- 设置maven自动导入jar包 settings -> Build Tools -> Maven -> Importinng 选择 `Import Maven project automatically`

创建Maven工程

  • 创建Maven工程

image-20210707120400854

  • 输入maven工程名

image-20210707120440836

删除src目录

这里我们使用mybatis-source maven工程做为父工程

image-20210707151600445

修改 Pom.xml 文件

修改pom.xml文件。添加 <packaging>pom</packaging> 这一行。

	<groupId>org.hosystem</groupId>    
	<artifactId>mybatis-source</artifactId>    
	<packaging>pom</packaging>    
	<version>1.0-SNAPSHOT</version>

复制mybatis-parent 到 Maven 工程

打开mybatis-source目录,将mybatis和mybatis-parent复制到该目录中。

image-20210707152335154

pom.xml中module标签添加模块信息。点右边的Maven 刷新 若出现三个工程则成功构建。

    <modules>
        <module>mybatis-3-mybatis-3.5.0</module>
        <module>parent-mybatis-parent-31</module>
    </modules>

image-20210707152221944

设置自动导入

设置maven为Import Maven project automatically即可,右侧Maven中刷新即可。等待导入jar包就可以构建成功了!

image-20210707152607069

posted @ 2021-07-07 19:42  HOsystem  阅读(351)  评论(0编辑  收藏  举报