情景介紹

編寫(xiě)代碼的過(guò)程中,我們總希望能有一個(gè)插件能快速生成公用的相似的代碼。感覺(jué)mybatis-generator用起來(lái)不錯(cuò)。下面就來(lái)總結(jié)一下它的使用方法。
使用步驟
一、新建generator.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration>
<!-- 引入配置文件 -->
<!--TODO 注意!!!自動(dòng)生成代碼 要把這句放開(kāi),鏈接數(shù)據(jù)庫(kù)-->
<properties resource="jdbc.properties"/>
<!-- 指定數(shù)據(jù)連接驅(qū)動(dòng)jar地址 -->
<classPathEntry location="F:\SVN_Info\cloudTree\trustzhyq\src\e3izm\src\main\webapp\WEB-INF\lib\mysql-connector-java-5.1.29.jar"/>
<context id="context" targetRuntime="MyBatis3">
<commentGenerator>
<!-- 是否去除自動(dòng)生成的注釋 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
<property name="suppressDate" value="true"/>
</commentGenerator>
<!-- 數(shù)據(jù)庫(kù)的相關(guān)配置 -->
<jdbcConnection driverClass="${driverClasss}" connectionURL="${jdbcUrl}"
userId="${username}" password="${password}"/>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 實(shí)體類(lèi)生成的位置 -->
<javaModelGenerator targetPackage="com.trust.e3izm.ressvc.entity" targetProject="src/main/java">
<property name="enableSubPackages" value="false"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- *Mapper.xml 文件的位置 ,targetPackage:包名,targetProject:項(xiàng)目下的路徑-->
<sqlMapGenerator targetPackage="ressvc" targetProject="src/main/resources/mapper">
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
<!-- Mapper 接口文件的位置 -->
<javaClientGenerator targetPackage="com.trust.e3izm.ressvc.dao" targetProject="src/main/java" type="XMLMAPPER">
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
<!-- 配置表信息 -->
<!--第三方服務(wù)類(lèi)型-->
<table schema="e3iz" tableName="THIRDPTYSVC_TYPE"
domainObjectName="Thirdptysvc_type" enableCountByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
enableUpdateByExample="false">
</table>
<!--xxtable-->
<!--如果生成n個(gè)表,那就將上面的那段table代碼copy n份-->
</context>
</generatorConfiguration>
網(wǎng)頁(yè)標(biāo)題:IntelliJIDEA中使用mybatis-generator的示例-創(chuàng)新互聯(lián)
網(wǎng)站路徑:http://chinadenli.net/article44/hhche.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、網(wǎng)站維護(hù)、微信小程序、自適應(yīng)網(wǎng)站、網(wǎng)站排名、服務(wù)器托管
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容