国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Mybatis自動生成dao,mapping,model文件

2019-11-08 20:22:51
字體:
來源:轉載
供稿:網友

相關步驟:

       1.下載mybatis-generator-core.zip

       2.在將其解壓后進入lib目錄下   a.新建src文件夾(用于存放生成的文件)   b.新建generatorConfig.xml文件   c.將MySQL-connector-java.jar添加進來

       3.桶過控制臺進入下載的mybatis-generator-core文件夾下的lib目錄下,使用命令:java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite即可生成相應代碼。

generatorConfig.xml(生成的三個包的時候建議采用下面的.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>    <!-- 數據庫驅動-->        <classPathEntry  location="mysql-connector-java-5.1.39-bin.jar"/>        <context id="DB2Tables"  targetRuntime="MyBatis3">            <commentGenerator>                <PRoperty name="suppressDate" value="true"/>                <!-- 是否去除自動生成的注釋 true:是 : false:否 -->                <property name="suppressAllComments" value="true"/>            </commentGenerator>            <!--數據庫鏈接URL,用戶名、密碼 -->            <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/ssm" userId="root" passWord="">            </jdbcConnection>            <javaTypeResolver>                <property name="forceBigDecimals" value="false"/>            </javaTypeResolver>            <!-- 生成模型的包名和位置-->            <javaModelGenerator targetPackage="dqd.model" targetProject="src">                <property name="enableSubPackages" value="true"/>                <property name="trimStrings" value="true"/>            </javaModelGenerator>            <!-- 生成映射文件的包名和位置-->            <sqlMapGenerator targetPackage="dqd.mapping" targetProject="src">                <property name="enableSubPackages" value="true"/>            </sqlMapGenerator>            <!-- 生成DAO的包名和位置-->            <javaClientGenerator type="XMLMAPPER" targetPackage="dqd.dao" targetProject="src">                <property name="enableSubPackages" value="true"/>            </javaClientGenerator>		        <!-- 要生成的表 tableName是數據庫中的表名或視圖名 domainObjectName是實體類名-->            <table tableName="user_t" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>      </context>    </generatorConfiguration>  

generator.xml-----enhance:

<?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>	<!-- 數據庫驅動包位置 -->	<!-- <classPathEntry location="D:/software/lib/mysql-connector-java-5.1.21.jar" /> -->	<classPathEntry location="C:/Oracle/product/10.2.0/db_1/jdbc/lib/ojdbc14.jar" />	<context id="DB2Tables" targetRuntime="MyBatis3">		<commentGenerator>			<property name="suppressAllComments" value="true" />		</commentGenerator>		<!-- 數據庫鏈接URL、用戶名、密碼 -->		<!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/sy" userId="sypro" password="sypro"> -->		<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@localhost:1521:orcl" userId="msa" password="msa">		</jdbcConnection>		<javaTypeResolver>			<property name="forceBigDecimals" value="false" />		</javaTypeResolver>		<!-- 生成模型的包名和位置 -->		<javaModelGenerator targetPackage="sy.model" targetProject="D:/study/mybatis/src">			<property name="enableSubPackages" value="true" />			<property name="trimStrings" value="true" />		</javaModelGenerator>		<!-- 生成的映射文件包名和位置 -->		<sqlMapGenerator targetPackage="sy.mapping" targetProject="D:/study/mybatis/src">			<property name="enableSubPackages" value="true" />		</sqlMapGenerator>		<!-- 生成DAO的包名和位置 -->		<javaClientGenerator type="XMLMAPPER" targetPackage="sy.dao" targetProject="D:/study/mybatis/src">			<property name="enableSubPackages" value="true" />		</javaClientGenerator>		<!-- 要生成那些表(更改tableName和domainObjectName就可以) -->		<table tableName="tbug" domainObjectName="Bug" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />		<table tableName="tmenu" domainObjectName="Menu" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />		<table tableName="tonline" domainObjectName="Online" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />		<table tableName="tresource" domainObjectName="Resource" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />		<table tableName="trole" domainObjectName="Role" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />		<table tableName="trole_tresource" domainObjectName="RoleResource" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />		<table tableName="tuser" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />		<table tableName="tuser_trole" domainObjectName="UserRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />	</context></generatorConfiguration>


上一篇:求第k大

下一篇:A1100. Mars Numbers (20)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 高安市| 桃园县| 永新县| 寿宁县| 永昌县| 宜兰市| 彭山县| 北流市| 大余县| 姚安县| 公安县| 吉木乃县| 昌宁县| 洛宁县| 通许县| 武汉市| 克拉玛依市| 鄂州市| 大埔县| 石河子市| 寿宁县| 托克逊县| 剑川县| 遵化市| 古丈县| 专栏| 兴宁市| 灵台县| 平原县| 石城县| 沧源| 逊克县| 尼玛县| 宝山区| 如皋市| 即墨市| 鄯善县| 宣恩县| 游戏| 凤凰县| 叶城县|