首页 > 其他 > 详细

mybatis逆向工程mvn插件

时间:2019-07-19 16:56:50      阅读:93      评论:0      收藏:0      [点我收藏+]

pom.xml

      <plugins>
        <!-- Tomcat插件 -->
        <plugin>
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat7-maven-plugin</artifactId>
          <version>2.2</version>
          <configuration>
            <port>80</port>
            <path>/</path>
            <uriEncoding>UTF-8</uriEncoding>
          </configuration>
        </plugin>
          <!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-maven-plugin -->
        <plugin>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-maven-plugin</artifactId>
            <version>1.3.5</version>
        </plugin>
          
      </plugins>

 

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>
    <!--数据库驱动jar -->
    <classPathEntry location="C:\SoftData\maven\repository\mysql\mysql-connector-java\5.1.44\mysql-connector-java-5.1.44.jar" />

    <!--<context id="DB2Tables" targetRuntime="Ibatis2Java5">-->
    <context id="myConfig" targetRuntime="Mybatis3">
        <!--去除注释 (true好像不起作用) -->
        <commentGenerator>
            <property name="suppressAllComments" value="true" />
        </commentGenerator>

        <!--数据库连接 -->
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/aaos_platform_zjkb"
                        userId="root"
                        password="root123">
        </jdbcConnection>

        <!--生成Dao文件 可以配置 type="XMLMAPPER"生成xml的dao实现  context id="DB2Tables" 修改targetRuntime="MyBatis3"  -->
        <!--<javaClientGenerator type="SPRING" targetPackage="com.project.aaos.dao"  targetProject="D:\Mine\code">
            <property name="enableSubPackages" value="false" />
        </javaClientGenerator>-->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.project.aaos.dao"  targetProject="D:\temp"/>

        <!--默认false
           Java type resolver will always use java.math.BigDecimal if the database column is of type DECIMAL or NUMERIC.
         -->
        <javaTypeResolver >
            <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>


        <!--生成实体类 指定包名 以及生成的地址 (可以自定义地址,但是路径不存在不会自动创建  使用Maven生成在target目录下,会自动创建) -->
        <javaModelGenerator targetPackage="com.project.aaos.pojo" targetProject="D:\temp">
            <property name="enableSubPackages" value="false" />
            <property name="trimStrings" value="true" />
        </javaModelGenerator>
        <!--生成SQLMAP文件 -->
        <sqlMapGenerator targetPackage="com.project.aaos.dao"  targetProject="D:\temp">
            <property name="enableSubPackages" value="false" />
        </sqlMapGenerator>



        <!--对应数据库表 mysql可以加入主键自增 字段命名 忽略某字段等-->
        <table schema="aaos_platform_zjkb" tableName="appro_file" domainObjectName="ApproFileInfo"  enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" >
            <property name="useActualColumnNames" value="true" />
        </table>
        <!--<table schema="aaos_platform_zjkb"  tableName="appro_line" domainObjectName="ApproLineInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" >
            <property name="useActualColumnNames" value="true" />
        </table>-->
    </context>
</generatorConfiguration>

 

命令

mvn  mybatis-generator:generate

mybatis逆向工程mvn插件

原文:https://www.cnblogs.com/scorates/p/11214167.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!