国产探花免费观看_亚洲丰满少妇自慰呻吟_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)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 浑源县| 婺源县| 济宁市| 甘南县| 湖口县| 咸丰县| 阜城县| 抚松县| 乌海市| 徐水县| 永修县| 淮安市| 金湖县| 彭山县| 彭泽县| 广宗县| 盐源县| 赤峰市| 定襄县| 苍梧县| 乌兰浩特市| 霍山县| 大悟县| 如东县| 张北县| 印江| 玉环县| 虎林市| 牙克石市| 祥云县| 驻马店市| 沂源县| 卢龙县| 佛冈县| 土默特左旗| 鲁甸县| 类乌齐县| 类乌齐县| 织金县| 广灵县| 广汉市|