文章目录

why?

文章目录

how

看文档把。。

<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>

	<!-- 必要 -->
  	<context id="simple" targetRuntime="MyBatis3Simple">
  
	<!-- 指定如何连到目标数据库 -->
    <!-- 要改 --><jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="xxxx?useUnicode=true&amp;characterEncoding=utf-8" password="xxx" userId="xxx"/>

	<!-- 类型解析器 -->
	<javaTypeResolver>			
	<!-- When the property is true, the Java type resolver will always use java.math.BigDecimal if the database column is of type DECIMAL or NUMERIC. -->
		<property name="forceBigDecimals" value="false"/>
	</javaTypeResolver>

	<!-- 定义javaBean的生成策略 targetPackage 目标包名 targetProject 目标工程 -->
	<!-- 要改 --><javaModelGenerator targetPackage="com.bibi.generator.bean" targetProject="src/main/java">
		<property name="enableSubPackages" value="true"/><!-- 包含子包 -->
		<property name="trimStrings" value="true"/><!-- When true, MyBatis Generator will insert code to trim character fields. -->
	</javaModelGenerator>

	<!-- sql映射生成策略 -->
	<!-- 要改 --><sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
		<property name="enableSubPackages" value="true"/><!-- 包含子包 -->
	</sqlMapGenerator>
	
	<!-- 指定mapper接口所在的位置 -->
    <!-- 要改 --><javaClientGenerator type="XMLMAPPER" targetPackage="com.bibi.generator.dao" targetProject="src/main/java">
		<property name="enableSubPackages" value="true"/><!-- 包含子包 -->
    </javaClientGenerator>
    
	
	<!-- 指定要逆向分析哪些表:根据要创建javaBean -->
	<table tableName="user" domainObjectName="User"></table>
	<table tableName="user_state" domainObjectName="UserState"></table>
  </context>
</generatorConfiguration>