IDEA mybatis-generator逆向工程生成代码

2025-05-29 0 44

1.在maven工程中的resource中创建generatorconfig.xml

IDEA mybatis-generator逆向工程生成代码

2.配置generatorconfig.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
<?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="c:\\users\\xx\\.m2\\repository\\mysql\\mysql-connector-java\\5.1.35\\mysql-connector-java-5.1.35.jar"/>

<context id="db2tables" targetruntime="mybatis3">

<commentgenerator>

<property name="suppressdate" value="true"/>

<!-- 是否去除自动生成的注释 true:是 : false:否 -->

<property name="suppressallcomments" value="true"/>

</commentgenerator>

<!--数据库链接url,用户名、密码 -->

<jdbcconnection driverclass="com.mysql.jdbc.driver" connectionurl="jdbc:mysql://xx:3306/xx" userid="xx" password="xx">

</jdbcconnection>

<javatyperesolver>

<property name="forcebigdecimals" value="false"/>

</javatyperesolver>

<!-- 生成模型的包名和位置-->

<javamodelgenerator targetpackage="com.info.statistics.model" targetproject="src/main/java">

<property name="enablesubpackages" value="true"/>

<property name="trimstrings" value="true"/>

</javamodelgenerator>

<!-- 生成映射文件的包名和位置-->

<sqlmapgenerator targetpackage="com.info.statistics.mapping" targetproject="src/main/java">

<property name="enablesubpackages" value="true"/>

</sqlmapgenerator>

<!-- 生成dao的包名和位置-->

<javaclientgenerator type="xmlmapper" targetpackage="com.info.statistics.dao" targetproject="src/main/java">

<property name="enablesubpackages" value="true"/>

</javaclientgenerator>

<!-- 要生成的表 tablename是数据库中的表名或视图名 domainobjectname是实体类名-->

<table tablename="risk_model_order" domainobjectname="dsriskmodelorder" enablecountbyexample="false" enableupdatebyexample="false" enabledeletebyexample="false" enableselectbyexample="false" selectbyexamplequeryid="false"></table>

<table tablename="tel_bill_record" domainobjectname="dstelbillrecord" enablecountbyexample="false" enableupdatebyexample="false" enabledeletebyexample="false" enableselectbyexample="false" selectbyexamplequeryid="false"></table>

</context>

</generatorconfiguration>

3.配置pom.xml

?

1

2

3

4

5

6

7

8

9

10
<plugin>

<groupid>org.mybatis.generator</groupid>

<artifactid>mybatis-generator-maven-plugin</artifactid>

<version>1.3.2</version>

<configuration>

<configurationfile>/src/main/resources/generator/generatorconfig.xml</configurationfile>

<overwrite>true</overwrite>

<verbose>true</verbose>

</configuration>

</plugin>

4.生成对象的两种方式

方式一:使用idea的maven插件直接快速生成

双击mybatis-generator:generate就可生成

IDEA mybatis-generator逆向工程生成代码

方式二:在idea添加一个“run运行”选项,使用maven运行mybatis-generator-maven-plugin插件

mybatis-generator:generate -e 加-e是为了输出详细信息

IDEA mybatis-generator逆向工程生成代码

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持快网idc。

原文链接:http://www.cnblogs.com/fswhq/p/mybatis-generator.html

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 IDEA mybatis-generator逆向工程生成代码 https://www.kuaiidc.com/111401.html

相关文章

发表评论
暂无评论