maven 自动生成mybatis代码

    <!-- dependency和plugin中jar的版本根据自己需求选择,但同一个jar版本要保持一致 -->
    <!-- 配置在dependencies中 -->
    <dependency>
      <groupId>org.mybatis.generator</groupId>
      <artifactId>mybatis-generator-core</artifactId>
      <version>1.3.7</version>
    </dependency>

<!-- 在build中,注意,不要写在pluginManagement中,另起一段,单独写plugins -->
<plugins>
      <plugin>
        <groupId>org.mybatis.generator</groupId>
        <artifactId>mybatis-generator-maven-plugin</artifactId>
        <version>1.3.7</version>
        <dependencies>
          <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <version>19.16.0.0</version>
          </dependency>
        </dependencies>
        <configuration>
          <overwrite>true</overwrite>
          <!--<configurationFile>./generatorConfig.xml</configurationFile>-->
        </configuration>
      </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>

    <!--
    https://blog.csdn.net/weixin_43245066/article/details/119860351
    -->

    <!-- mysql-connector-java 版本需要与pom中引得版本一致 -->
    <classPathEntry location="C:\enviorment\repository\com\oracle\database\jdbc\ojdbc8\19.16.0.0\ojdbc8-19.16.0.0.jar" />

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

        <!-- 不加注释,因为默认注释是英文的 -->
        <commentGenerator>
            <property name="addRemarkComments" value="true"/>
            <property name="suppressDate" value="true"/>
        </commentGenerator>

        <!-- 数据库连接信息 -->
        <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
                        connectionURL="jdbc:oracle:thin:@es111:1521:orcl"
                        userId="fsxt_1"
                        password="123456">
        </jdbcConnection>

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


        <!-- targetPackage 文件生成在指定包下,targetProject 路径-->
        <javaModelGenerator targetPackage="com.cz.mhm.entity" targetProject="src/main/java">
            <property name="enableSubPackages" value="true" />
            <property name="trimStrings" value="true" />
        </javaModelGenerator>

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

        <javaClientGenerator type="XMLMAPPER" targetPackage="com.cz.mhm.dao"  targetProject="src/main/java">
            <property name="enableSubPackages" value="true" />
        </javaClientGenerator>

        <!-- 数据库表以及对应的java模型类名(如果是多个表的话,可以复制多份然后修改成对应的表以及需要生成的模型名) -->
        <!-- 入模指标-申请额-季度和月度 -->
        <!--
        <table tableName="DM_RMZB_SQ_JIDU" domainObjectName="ShenqingJidu"
               enableCountByExample="false" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>

        <table tableName="DM_RMZB_SQ_YUEDU" domainObjectName="ShenqingYuedu"
               enableCountByExample="false" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
        -->

        <!-- 入模指标 归集额-季度和月度 -->
        <!--
        <table tableName="DM_RMZB_GJ_JIDU" domainObjectName="GuijiJidu"
               enableCountByExample="false" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>

        <table tableName="DM_RMZB_GJ_YueDU" domainObjectName="GuijiYuedu"
               enableCountByExample="false" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
        -->

        <!-- 入模指标 回收额-季度和月度 -->
        <!--
        <table tableName="DM_RMZB_HS_JIDU" domainObjectName="HuishouJidu"
               enableCountByExample="false" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>

        <table tableName="DM_RMZB_HS_YUEDU" domainObjectName="HuishouYuedu"
               enableCountByExample="false" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
        -->

        <!-- 入模指标 提取额-季度和月度 -->
        <table tableName="DM_RMZB_TQ_JIDU" domainObjectName="TiquJidu"
               enableCountByExample="false" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>

        <table tableName="DM_RMZB_TQ_YUEDU" domainObjectName="TiquYuedu"
               enableCountByExample="false" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>

    </context>
</generatorConfiguration>

 

执行

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值