1. 程式人生 > >使用Mybatis-Generator自動生成Dao、Model、Mapping相關檔案

使用Mybatis-Generator自動生成Dao、Model、Mapping相關檔案

複製程式碼 複製程式碼
 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="mysql-connector-java-5.0.8-bin.jar"/>
 8     <context id="DB2Tables"    targetRuntime="MyBatis3">
 9         <commentGenerator>
10             <property name="suppressDate" value="true"/>
11             <property name="suppressAllComments" value="true"/>
12         </commentGenerator>
13         <!--資料庫連結地址賬號密碼-->
14         <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/mymessages" userId="root" password="root">
15         </jdbcConnection>
16         <javaTypeResolver>
17             <property name="forceBigDecimals" value="false"/>
18         </javaTypeResolver>
19         <!--生成Model類存放位置-->
20         <javaModelGenerator targetPackage="lcw.model" targetProject="src">
21             <property name="enableSubPackages" value="true"/>
22             <property name="trimStrings" value="true"/>
23         </javaModelGenerator>
24         <!--生成對映檔案存放位置-->
25         <sqlMapGenerator targetPackage="lcw.mapping" targetProject="src">
26             <property name="enableSubPackages" value="true"/>
27         </sqlMapGenerator>
28         <!--生成Dao類存放位置-->
29         <javaClientGenerator type="XMLMAPPER" targetPackage="lcw.dao" targetProject="src">
30             <property name="enableSubPackages" value="true"/>
31         </javaClientGenerator>
32         <!--生成對應表及類名-->
33         <table tableName="message" domainObjectName="Messgae" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
34     </context>
35 </generatorConfiguration>
複製程式碼 複製程式碼