mybatis-generator有三种用法

mybatis-generator有三种用法:命令行、eclipse插件、maven插件。

maven插件

一、在pom.xml中添加plugin

<plugins>
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.2</version>
                 <configuration>

 <configurationFile>src/main/resources/mybatis-generator/generatorConfig.xml</configurationFile>
                    <verbose>true</verbose>
                    <overwrite>true</overwrite>
                </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>  
   <!-- classPathEntry:数据库的JDBC驱动,换成你自己的驱动位置 -->  
    <classPathEntry  location="E:\java\mybatis-generator-core-1.3.2\lib\mysql-connector-java-5.1.25-bin.jar"/>  
    <context id="DB2Tables"  targetRuntime="MyBatis3">  
        <commentGenerator>  
            <property name="suppressDate" value="true"/>  
           <!-- 去除自动生成的注释 -->  
            <property name="suppressAllComments" value="true"/>  
        </commentGenerator>  
         <!-- 数据库连接配置 -->   
        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1/eseip" userId="victool" password="victool">  
        </jdbcConnection>  
        <javaTypeResolver>  
            <property name="forceBigDecimals" value="false"/>  
        </javaTypeResolver>  
       <!-- targetProject:自动生成代码的位置 -->
        <javaModelGenerator targetPackage="test.domain" targetProject="E:\java\mybatis-generator-core-1.3.2\lib\src">  
            <property name="enableSubPackages" value="true"/>  
            <property name="trimStrings" value="true"/>  
        </javaModelGenerator>  
       <!-- targetProject:自动生成代码的位置 -->
        <sqlMapGenerator targetPackage="test.mapping" targetProject="E:\java\mybatis-generator-core-1.3.2\lib\src">  
            <property name="enableSubPackages" value="true"/>  
        </sqlMapGenerator>  
      <!-- targetProject:自动生成代码的位置 -->
        <javaClientGenerator type="XMLMAPPER" targetPackage="test.IDao" targetProject="E:\java\mybatis-generator-core-1.3.2\lib\src">  
            <property name="enableSubPackages" value="true"/>  
        </javaClientGenerator>  
       <!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 -->
        <table tableName="ac_account" domainObjectName="AcAccountDef" />
        <table tableName="ac_account_area" domainObjectName="AcAccountAreaDef" />
        
         <table tableName="ac_account" domainObjectName="AcAccountDef" />
        <table tableName="ac_account_area" domainObjectName="AcAccountAreaDef" />
        <!-- <table tableName="activity_info" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
 
    </context>  
</generatorConfiguration> 

:项目 右键--》run as --》 maven bulid --》弹出对话框 --》在goals中输入mybatis-generator:generate 或者 点击select --》选择你的mybatis插件 --》apply --》run
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值