日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用Mybatis Generator结合Ant脚本快速自动生成Model、Mapper等文件的方法

發布時間:2025/3/8 编程问答 11 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用Mybatis Generator结合Ant脚本快速自动生成Model、Mapper等文件的方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

新建generatorConfig.xml和build_mybatis.xml:

jar下載

<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
</dependency>

?

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.29</version>
</dependency>

  

generatorConfig.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>
<!-- <properties resource="database-config.properties" /> -->
<!-- 如果命令行運行,則需要加入此jar,放到跟 mybatis-generator-core-1.3.2.jar一起 -->
<!-- 如果通過程序,則用WalletMyBatisGenerator生成,不用配置 classPathEntry -->
<classPathEntry location="mysql-connector-java-5.1.29.jar" />

<context id="context1" targetRuntime="MyBatis3">
<plugin type="org.mybatis.generator.plugins.CaseInsensitiveLikePlugin" />
<plugin type="org.mybatis.generator.plugins.RenameExampleClassPlugin">
<property name="searchString" value="Example$" />
<property name="replaceString" value="Criteria" />
</plugin>

<commentGenerator>
<!-- 刪除代碼中帶有 代碼生成器的注釋信息 -->
<property name="suppressAllComments" value="true" />
<property name="suppressDate" value="true" />
</commentGenerator>

<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/nfc_pay_db" userId="dba"
password="hlw_mysql" />

<javaModelGenerator targetPackage="com.gionee.nfcPay.vo.models"
targetProject="../java" />
<sqlMapGenerator targetPackage="com.gionee.nfcPay.dao.impl.mapper"
targetProject="." />
<javaClientGenerator targetPackage="com.gionee.nfcPay.dao.mapper"
targetProject="../java" type="XMLMAPPER" />

<table tableName="nfc_union_trans_result_notify_tb" schema="nfc_pay_db"
enableSelectByExample="false" enableDeleteByExample="false"
enableCountByExample="false" enableUpdateByExample="fasle">
<property name="useActualColumnNames" value="true"/>
</table>

</context>
</generatorConfiguration>

build_mybatis.xml:

  

<project default="genfiles" basedir="."><property name="generated.source.dir" value="${basedir}" /><path id="ant.run.lib.path"><pathelement location="mybatis-generator-core-1.3.2.jar" /></path><target name="genfiles" description="Generate the files"><taskdef name="mbgenerator" classname="org.mybatis.generator.ant.GeneratorAntTask" classpathref="ant.run.lib.path" /><mbgenerator overwrite="true" configfile="generatorConfig.xml" verbose="false"><propertyset><propertyref name="generated.source.dir" /></propertyset></mbgenerator></target> </project>

鼠標右擊build_mybatis.xml文件Run as --> Ant build運行   

 

?

轉載于:https://www.cnblogs.com/xlhan/p/7145653.html

總結

以上是生活随笔為你收集整理的使用Mybatis Generator结合Ant脚本快速自动生成Model、Mapper等文件的方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。