0%

MyBatis-generator使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?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>
<!-- windows下路径, D:\downloads\xxx.jar-->
<classPathEntry location="D:\mysql-connector-java-5.1.6.jar" />

<context id="DB2Tables" targetRuntime="MyBatis3">

<!-- 不再追加xml内容-->
<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />

<commentGenerator>
<property name="suppressAllComments" value="true"/>
</commentGenerator>

<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/mall?characterEncoding=utf-8"
userId="root"
password="123456">
</jdbcConnection>

<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>

<javaModelGenerator targetPackage="tech.xixing.qaqmall.pojo" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
<!-- <property name="trimStrings" value="true" />-->
</javaModelGenerator>

<sqlMapGenerator targetPackage="mappers" targetProject="src/main/resources">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>

<javaClientGenerator type="XMLMAPPER" targetPackage="tech.xixing.qaqmall.dao" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>

<!-- <table tableName="mall_order" domainObjectName="Order" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>-->
<!-- <table tableName="mall_order_item" domainObjectName="OrderItem" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>-->
<!-- <table tableName="mall_user" domainObjectName="User" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>-->
<!-- <table tableName="mall_category" domainObjectName="Category" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>-->
<!-- <table tableName="mall_product" domainObjectName="Product" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false">-->
<!-- <columnOverride column="detail" jdbcType="VARCHAR" />-->
<!-- <columnOverride column="sub_images" jdbcType="VARCHAR" />-->
<!-- </table>-->
<table tableName="mall_user" domainObjectName="User" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>

</context>
</generatorConfiguration>

上面是generatorConfig.xml

在cmd运行mvn mybatis-generator:generate即可自动生成文件