mybatis-generator-config工具的使用

时间:2023-03-09 02:15:25
mybatis-generator-config工具的使用

generator.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用于设置数据库驱动包位置-->  
</pre><pre code_snippet_id="485664" snippet_file_name="blog_20141016_1_6249858" name="code" class="html">  
<classPathEntry location="F:\jar\mysql-connector-java-5.1.25\mysql-connector-java-5.1.25\mysql-connector-java-5.1.22-bin.jar"/>  
<!-- targetRuntime:代码生成目标,默认是MyBatis3-->  
<context id="DB2Tables" targetRuntime="MyBatis3">  
<commentGenerator>  
<property name="suppressAllComments" value="true"/>  
</commentGenerator>  
<!-- 数据库连接的信息 -->  
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test" userId="root" password="root">  
</jdbcConnection>  
<!-- 解决数据转换问题 -->  
<javaTypeResolver>  
<!--是否强制使用BigDecimal来表示所有的十进制和数值字段。-->  
<property name="forceBigDecimals" value="false" />  
</javaTypeResolver>  
<!--生成模型的包名和位置-->  
<javaModelGenerator targetPackage="project.model" targetProject="E:\mybatis\src">  
<property name="enableSubPackages" value="true" />  
<property name="trimStrings" value="true" />  
</javaModelGenerator>  
<!--生成的映射文件包名和位置-->  
<sqlMapGenerator targetPackage="project.mapping" targetProject="E:\mybatis\src">  
<property name="enableSubPackages" value="true" />  
</sqlMapGenerator>  
<!--生成DAO的包名和位置-->  
<javaClientGenerator type="XMLMAPPER" targetPackage="project.dao" targetProject="E:\mybatis\src">  
<property name="enableSubPackages" value="true" />  
</javaClientGenerator>  
<!--要生成那些文件-->  
<!--<table tableName="表名"  domainObjectName="类名"></table>-->  
<table tableName="t_user" domainObjectName="User"  enableCountByExample="false" enableUpdateByExample="false"  
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
  </context>   </generatorConfiguration>