逆向工程

逆向工程文件

  1. 配置文件generator.xml如下:
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?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="D:\Program Files\repository\mysql\mysql-connector-java\5.1.34\mysql-connector-java-5.1.34.jar"/>
<context id="test" targetRuntime="MyBatis3">
<!-- 一些工具 -->
<!-- <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin"></plugin>-->
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin>
<!--<plugin type="org.mybatis.generator.plugins.ToStringPlugin"></plugin>-->
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!--数据库链接 参数 -->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://10.243.212.206:3306/bwcar" userId="sun"
password="123456">
</jdbcConnection>
<javaTypeResolver>
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和
NUMERIC 类型解析为java.math.BigDecimal -->
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- 生成模型的包名和位置 -->
<javaModelGenerator targetPackage="top.fulsun.pojo"
targetProject="src/main/java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="true" />
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- 生成映射文件的包名和位置 -->
<sqlMapGenerator targetPackage="mapper"
targetProject="src/main/resources">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<!-- 生成DAO的包名和位置 -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="top.fulsun.dao" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>

<!-- 要生成哪些表 -->
<table tableName="sys_menu" domainObjectName="SysMenu"></table>
<table tableName="sys_role" domainObjectName="SysRole"></table>
<table tableName="sys_user" domainObjectName="SysUser"></table>
<table tableName="sys_role_menu" domainObjectName="SysRoleMenu"></table>
<table tableName="sys_user_role" domainObjectName="SysUserRole"></table>
<table tableName="sys_config" domainObjectName="SysConfig"></table>
<table tableName="sys_log" domainObjectName="SysLog"></table>
<table tableName="schedule_job" domainObjectName="ScheduleJob"></table>
<table tableName="schedule_job_log" domainObjectName="ScheduleJobLog"></table>
<table tableName="activity" domainObjectName="Activity"></table>
<table tableName="activity_car" domainObjectName="ActivityCar"></table>
<table tableName="activity_category" domainObjectName="ActivityCategory"></table>
<table tableName="activity_channel" domainObjectName="ActivityChannel"></table>
<table tableName="activity_dealer" domainObjectName="ActivityDealer"></table>
<table tableName="activity_interface" domainObjectName="ActivityInterface"></table>
<table tableName="activity_key" domainObjectName="ActivityKey"></table>
<table tableName="activity_link" domainObjectName="ActivityLink"></table>
<table tableName="activity_pdata" domainObjectName="ActivityPdata"></table>
<table tableName="activity_tag" domainObjectName="ActivityTag"></table>
<table tableName="admin_menu_auth" domainObjectName="AdminMenuAuth"></table>
<table tableName="admin_role" domainObjectName="AdminRole"></table>
<table tableName="admin_role_menu" domainObjectName="AdminRoleMenu"></table>
<table tableName="admin_user" domainObjectName="AdminUser"></table>
<table tableName="admin_user_role" domainObjectName="AdminUserRole"></table>
<table tableName="area" domainObjectName="Area"></table>
<table tableName="article" domainObjectName="Article"></table>
<table tableName="article_action" domainObjectName="ArticleAction"></table>
<table tableName="article_category" domainObjectName="ArticleCategory"></table>
<table tableName="article_tag" domainObjectName="ArticleTag"></table>
<table tableName="car" domainObjectName="Car"></table>
<table tableName="car_brand" domainObjectName="CarBrand"></table>
<table tableName="car_image" domainObjectName="CarImage"></table>
<table tableName="car_make" domainObjectName="CarMake"></table>
<table tableName="car_model" domainObjectName="CarModel"></table>
<table tableName="car_model_image" domainObjectName="CarModelImage"></table>
<table tableName="car_select_list" domainObjectName="CarSelectList"></table>
<table tableName="choose_log" domainObjectName="ChooseLog"></table>
<table tableName="dict_answer" domainObjectName="DictAnswer"></table>
<table tableName="dict_brand_point" domainObjectName="DictBrandPoint"></table>
<table tableName="dict_country" domainObjectName="DictCountry"></table>
<table tableName="dict_model" domainObjectName="DictModel"></table>
<table tableName="dict_weight" domainObjectName="DictWeight"></table>
<table tableName="member" domainObjectName="Member"></table>
<table tableName="member_car" domainObjectName="MemberCar"></table>
<table tableName="member_fav" domainObjectName="MemberFav"></table>
<table tableName="member_login_log" domainObjectName="MemberLoginLog"></table>
<table tableName="member_point" domainObjectName="MemberPoint"></table>
<table tableName="member_profile" domainObjectName="MemberProfile"></table>
<table tableName="member_profile_log" domainObjectName="MemberProfileLog"></table>
<table tableName="member_tag" domainObjectName="MemberTag"></table>
<table tableName="member_token" domainObjectName="MemberToken"></table>
<table tableName="message" domainObjectName="Message"></table>
<table tableName="message_sendlog" domainObjectName="MessageSendlog"></table>
<table tableName="operate_log" domainObjectName="OperateLog"></table>
<table tableName="product" domainObjectName="Product"></table>
<table tableName="product_car" domainObjectName="ProductCar"></table>
<table tableName="product_car_activity" domainObjectName="ProductCarActivity"></table>
<table tableName="sdk_interface" domainObjectName="SdkInterface"></table>
<table tableName="sdk_interface_info" domainObjectName="SdkInterfaceInfo"></table>
<table tableName="sdk_interface_parm" domainObjectName="SdkInterfaceParm"></table>
<table tableName="sdk_interface_type" domainObjectName="SdkInterfaceType"></table>
<table tableName="sdk_interface_udparm" domainObjectName="SdkInterfaceUdparm"></table>
<table tableName="sdk_temp" domainObjectName="SdkTemp"></table>
<table tableName="tag" domainObjectName="Tag"></table>
<table tableName="tb_token" domainObjectName="TbToken"></table>
<table tableName="tb_user" domainObjectName="TbUser"></table>
<table tableName="visit_log" domainObjectName="VisitLog"></table>
<table tableName="visitor" domainObjectName="Visitor"></table>
<table tableName="car_param_type" domainObjectName="CarParamType"></table>
<table tableName="car_params" domainObjectName="CarParams"></table>
<table tableName="car_manufacturer" domainObjectName="CarManufacturer"></table>
</context>
</generatorConfiguration>
  • 自行更改以下配置项

配置Maven依赖

  • 在pom文件添加Mybatis逆向工程插件和相应的依赖包-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
    <build>
    <plugins>
    <!--Mybatis逆向工程的插件-->
    <plugin>
    <groupId>org.mybatis.generator</groupId>
    <artifactId>mybatis-generator-maven-plugin</artifactId>
    <version>1.3.7</version>
    <configuration>
    <!--指定本地的逆向工程设置文件-->
    <configurationFile>src/main/resources/generator.xml</configurationFile>
    <configurationFile>${basedir}/src/main/resources/generator.xml</configurationFile>
    <verbose>true</verbose>
    <overwrite>true</overwrite>
    </configuration>
    <!--在插件配置数据库驱动包以防止插件运行找不到驱动包-->
    <dependencies>
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.13</version>
    </dependency>
    </dependencies>
    </plugin>
    </plugins>
    </build>
  • 修改的位置

执行逆向工程

  • 执行逆向工程