mybatis + maven 自动生成mapper

1、配置mavne插件
<plugins>
    <plugin>
        <groupId>org.mybatis.generator</groupId>
        <artifactId>mybatis-generator-maven-plugin</artifactId>
        <version>1.3.2</version>
        <configuration>
            <verbose>true</verbose>
            <overwrite>true</overwrite>
        </configuration>
    </plugin>

</plugins>

2、config配置文件

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

    <!--导入属性配置 -->
    <properties resource="generator.properties"></properties>  <!--配置文件对应路径-->
    <classPathEntry
            location="${jdbc.driverLocation}"/>
    <context id="my" targetRuntime="MyBatis3"> <!--此处配置类型,支持:ibatis Ibatis2Java5 MyBatis3-->
        <commentGenerator>
            <property name="suppressDate" value="false"/>
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>

        <jdbcConnection driverClass="${jdbc.driverClass}" connectionURL="${jdbc.connectionURL}" userId="${jdbc.userId}"
                        password="${jdbc.password}">
        </jdbcConnection>

        <javaModelGenerator targetPackage="com.admin.entity"
                            targetProject="src/main/java">
            <property name="enableSubPackages" value="true"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>

        <sqlMapGenerator targetPackage="com.admin.entity.xml"
                         targetProject="src/main/java">
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>

        <javaClientGenerator targetPackage="com.admin.mapper"
                             targetProject="src/main/java" type="XMLMAPPER" > <!--ibatis对应配置为:type="IBATIS"-->
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>

        <table tableName="gshop_reason_department_related" domainObjectName="ReasonDepartmentRelated"
       enableCountByExample="ture" enableUpdateByExample="ture"
       enableDeleteByExample="ture" enableSelectByExample="true"
       selectByExampleQueryId="ture">
           <!-- <columnOverride column="disabled" javaType="java.lang.Byte" jdbcType="BIT" />
            <columnOverride column="is_show" javaType="java.lang.Byte" jdbcType="BIT" />
            <columnOverride column="rank_id" javaType="java.lang.Byte" jdbcType="BIT" />
            <columnOverride column="is_recommend" javaType="java.lang.Byte" jdbcType="BIT" />
            <columnOverride column="type" javaType="java.lang.Byte" jdbcType="BIT" />-->

        </table>
     

    </context>
</generatorConfiguration>

3、配置属性文件:
jdbc.driverLocation=F:\\projects\\mysql-connector-java-5.1.33.jar
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.connectionURL=jdbc:mysql://####:3306/####
jdbc.userId=####
jdbc.password=#####

4、intellij  启动配置



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值