自動產生mybatis的model,mapper,xml工具的使用

來源:互聯網
上載者:User

標籤:xml檔案   ges   res   rtt   令行   png   ora   sub   tor   

首先把這三個檔案放到一個目錄裡,我是放到了C盤下的wangbo目錄下:

接下來就是設定config.xml檔案了,config.xml:

 1 <?xml version="1.0" encoding="UTF-8"?>   2 <!DOCTYPE generatorConfiguration   3 PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"   4 "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">   5 <generatorConfiguration>   6 <!-- 資料庫驅動-->   7 <classPathEntry  location="ojdbc14.jar"/> 8 <!--修改targetRuntime="MyBatis3"--> 9 <context id="DB2Tables"  targetRuntime="MyBatis3">10 <commentGenerator>  11 <property name="suppressDate" value="true"/>  12 <!-- 是否去除自動產生的注釋 true:是 : false:否 -->  13 <property name="suppressAllComments" value="true"/>  14 </commentGenerator>  15 <!--資料庫連結URL,使用者名稱、密碼 -->  16 <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@124.237.121.124:1521:ORADB" userId="album" password="sdfwetertertgdfgertrttt">  17 </jdbcConnection>  18 <javaTypeResolver>  19 <property name="forceBigDecimals" value="false"/>  20 </javaTypeResolver>  21 <!-- 產生模型的包名和位置-->  22 <javaModelGenerator targetPackage="test.model" targetProject="C:\wangbo\">23 <property name="enableSubPackages" value="true"/>  24 <property name="trimStrings" value="true"/>  25 </javaModelGenerator>  26 <!-- 產生對應檔的包名和位置-->  27 <sqlMapGenerator targetPackage="test.mapping" targetProject="C:\wangbo\">  28 <property name="enableSubPackages" value="false"/>  29 </sqlMapGenerator>  30 <!-- 產生DAO的包名和位置   type="XMLMAPPER"-->  31 <javaClientGenerator type="XMLMAPPER" targetPackage="test.dao" targetProject="C:\wangbo\">  32 <property name="enableSubPackages" value="true"/>  33 </javaClientGenerator>34 35 <!-- 要產生哪些表-->  36 <table tableName="XLW_USER_BRANCH" domainObjectName="UserBranch" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>37 </context>  38 </generatorConfiguration>  

下面解釋下需要配置的地方:

配置完後開啟cmd命令列,進入到設定檔所在的目錄下,執行命令就好了:

命令:java -jar mybatis-generator-core-1.3.2.jar -configfile config.xml -overwrite

接下來就產生好了test包:

 

自動產生mybatis的model,mapper,xml工具的使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.