美文网首页
记一次MyBatis逆向工程MyBatis-generator插

记一次MyBatis逆向工程MyBatis-generator插

作者: 凯尔特DD | 来源:发表于2020-02-21 17:50 被阅读0次

Mybatis generator plugins  官方文档

使用步骤如下:

1、引入依赖

    <plugin>

    <groupId>org.mybatis.generator</groupId>

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

<version>1.3.2</version>

<configuration>

<configurationFile>src/main/resources/mybatis/generatorConfig.xml</configurationFile>

<verbose>true</verbose>

<overwrite>true</overwrite>

</configuration>

<executions>

<execution>

<id>Generate MyBatis Artifacts</id>

<goals>

<goal>generate</goal>

</goals>

</execution>

</executions>

<dependencies>

<dependency>

<groupId>org.mybatis.generator</groupId>

<artifactId>mybatis-generator-core</artifactId>

<version>1.3.2</version>

</dependency>

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

<version>5.1.37</version>

<scope>runtime</scope>

</dependency>

</dependencies>

</plugin>

2、generatorConfig.xml的生成配置

        <?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>

<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>

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

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

</commentGenerator>

        <jdbcConnection driverClass="com.mysql.jdbc.Driver"

                        connectionURL="jdbc:mysql://192.168.50.211:3306/XXXX" userId="root" password="123456">

</jdbcConnection>

<javaTypeResolver>

force the use of java.math.BigDecimal for DECIMAL and NUMERIC fields, -->

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

</javaTypeResolver>

        <javaModelGenerator targetPackage="com.xuanyuan.entity.SmallProgram.req"

                            targetProject="target">

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

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

</javaModelGenerator>

        <sqlMapGenerator targetPackage="com.xuanyuan.mapping"

                        targetProject="target">

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

</sqlMapGenerator>

        <javaClientGenerator type="XMLMAPPER"

                            targetPackage="com.xuanyuan.dao" implementationPackage="com.xuanyuan.dao.impl"  targetProject="target">

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

</javaClientGenerator>

        <table tableName="smallprogram_userinfo" domainObjectName="SmallProgramUserInfoReq"

              enableCountByExample="false" enableUpdateByExample="false"

              enableDeleteByExample="false" enableSelectByExample="false"

              selectByExampleQueryId="false">

        </table>

enableCountByExample="false" enableUpdateByExample="false"

enableDeleteByExample="false" enableSelectByExample="false"

selectByExampleQueryId="false">

<!– 将表里面text或是大的字符按照以下形式改 –>

-->

    </context>

</generatorConfiguration>

3、在IDEA控制台执行以下命令:

mvn mybatis-generator:generate

4、完成后生成的结果文件

相关文章

网友评论

      本文标题:记一次MyBatis逆向工程MyBatis-generator插

      本文链接:https://www.haomeiwen.com/subject/omfhqhtx.html