mybatis-generator-config工具的使用

generator.xml

 1 <?xml version="1.0" encoding="UTF-8" ?>  
 2 <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >  
 3 <generatorConfiguration >  
 4 <!-- classPathEntry用于设置数据库驱动包位置-->  
 5 </pre><pre code_snippet_id="485664" snippet_file_name="blog_20141016_1_6249858" name="code" class="html">  
 6 <classPathEntry location="F:jarmysql-connector-java-5.1.25mysql-connector-java-5.1.25mysql-connector-java-5.1.22-bin.jar"/>  
 7 <!-- targetRuntime:代码生成目标,默认是MyBatis3-->  
 8 <context id="DB2Tables" targetRuntime="MyBatis3">  
 9 <commentGenerator>  
10 <property name="suppressAllComments" value="true"/>  
11 </commentGenerator>  
12 <!-- 数据库连接的信息 -->  
13 <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test" userId="root" password="root">  
14 </jdbcConnection>  
15 <!-- 解决数据转换问题 -->  
16 <javaTypeResolver>  
17 <!--是否强制使用BigDecimal来表示所有的十进制和数值字段。-->  
18 <property name="forceBigDecimals" value="false" />  
19 </javaTypeResolver>  
20 <!--生成模型的包名和位置-->  
21 <javaModelGenerator targetPackage="project.model" targetProject="E:mybatissrc">  
22 <property name="enableSubPackages" value="true" />  
23 <property name="trimStrings" value="true" />  
24 </javaModelGenerator>  
25 <!--生成的映射文件包名和位置-->  
26 <sqlMapGenerator targetPackage="project.mapping" targetProject="E:mybatissrc">  
27 <property name="enableSubPackages" value="true" />  
28 </sqlMapGenerator>  
29 <!--生成DAO的包名和位置-->  
30 <javaClientGenerator type="XMLMAPPER" targetPackage="project.dao" targetProject="E:mybatissrc">  
31 <property name="enableSubPackages" value="true" />  
32 </javaClientGenerator>  
33 <!--要生成那些文件-->  
34 <!--<table tableName="表名"  domainObjectName="类名"></table>-->  
35 <table tableName="t_user" domainObjectName="User"  enableCountByExample="false" enableUpdateByExample="false"  
36 enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
37   </context>  
38 
39 </generatorConfiguration>
View Code
原文地址:https://www.cnblogs.com/duanxianyouyang/p/6083277.html