更新時間:2022-12-05 10:42:36 來源:動力節點 瀏覽1785次
相信大家對什么是Mybatis已經有所了解,下面我們來了解一下MyBatis源碼下載編譯。
官網地址:https://github.com/mybatis/mybatis-3
選擇需要的版本下載。
本例下載的是 mybatis-3-mybatis-3.5.1,下載完后解壓。打開pom.xml,查看mybatis的依賴的父工程版本
選擇mybatis對應的mybatis-parent版本,本例版本是 mybatis-parent-31
在Idea中新建一個空項目,將 mybatis 、 mybatis-parent 都放到空項目下,并導入模塊
(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>-->
(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編程,感興趣的同學可以關注一下。
0基礎 0學費 15天面授
有基礎 直達就業
業余時間 高薪轉行
工作1~3年,加薪神器
工作3~5年,晉升架構
提交申請后,顧問老師會電話與您溝通安排學習