Mybatis

mybatis-generator 常见配置

<?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.28.jar"/>
	<context id="DB2Tables"	targetRuntime="MyBatis3">
		<commentGenerator> 
			<!--  关闭自动生成的注释  -->
			<property name="suppressAllComments" value="true" /> 
		</commentGenerator>
			<!--  数据库连接配置  -->
		<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/db" userId="root" password="root"></jdbcConnection>
			<!--  java类型处理器  -->
		<javaTypeResolver>
			<!--  不使用DECIMAL和 NUMERIC  -->
			<property name="forceBigDecimals" value="false"/>
		</javaTypeResolver>
			<!--  生成java类  -->
		<javaModelGenerator targetPackage="pojo" targetProject="src">
			<!-- 在targetPackage的基础上,根据数据库的schema再生成一层package,最终生成的类放在这个package下,默认为false -->
			<property name="enableSubPackages" value="true"/>
			<!-- 设置是否在getter方法中,对String类型字段调用trim()方法 -->
			<property name="trimStrings" value="true"/>
		</javaModelGenerator>
			<!--  生成mapper  -->
		<sqlMapGenerator targetPackage="mapper" targetProject="src">
			<property name="enableSubPackages" value="true"/>
		</sqlMapGenerator>
			<!--  生成xml  -->
		<javaClientGenerator type="XMLMAPPER" targetPackage="mapper" targetProject="src">
			<property name="enableSubPackages" value="true"/>
		</javaClientGenerator>
			
		<table tableName="table" domainObjectName="pojo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
		enableSelectByExample="false" selectByExampleQueryId="false">
		</table>

	</context>
</generatorConfiguration>

原文地址:https://www.cnblogs.com/qifengle1412/p/12933729.html