IDEA配置mybatis-generator的maven启动方式

下载插件 MyBatis Generator

File——Settings——Plugins
下载 free mybatis plugin 后重启

配置pom.xml

 <plugins>
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.5</version>
                <configuration>
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
                    <overwrite>true</overwrite>
                    <verbose>true</verbose>
                </configuration>
            </plugin>
  </plugins>

配置 generatorConfig.xml 文件

路径 src/main/resources 和pom.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="D:\apache-maven-3.2.1\repositorycloud\mysql\mysql-connector-java\8.0.19\mysql-connector-java-8.0.19.jar" />
  <context id="DB2Tables" defaultModelType="flat"
           targetRuntime="MyBatis3">
    <commentGenerator>
      <property name="suppressDate" value="true" />
      <!-- 是否去除自动生成的注释 true:是 : false:否 -->
      <property name="suppressAllComments" value="true" />
    </commentGenerator>
    <!--数据库链接地址账号密码 -->
    <jdbcConnection connectionURL="jdbc:mysql://localhost:3306/dwb"
                    driverClass="com.mysql.jdbc.Driver"
                    userId="root"
                    password="123456">
    </jdbcConnection>
    <!--生成Model类存放位置 -->
    <javaModelGenerator
            targetPackage="com.hp.careful.dao.entity" targetProject="src/main/java">
      <property name="enableSubPackages" value="true" />
      <property name="trimStrings" value="true" />
    </javaModelGenerator>
    <!--生成映射文件存放位置 -->
    <sqlMapGenerator targetPackage="com.hp.careful.dao.mapper"
                     targetProject="src/main/java">
      <property name="enableSubPackages" value="true" />
    </sqlMapGenerator>
    <!--生成Dao类存放位置 -->
    <javaClientGenerator
            targetPackage="com.hp.careful.dao" targetProject="src/main/java"
            type="XMLMAPPER">
      <property name="enableSubPackages" value="true" />
    </javaClientGenerator>
    <!--生成对应表及类名 -->
    <table tableName="cust_basic_info"
           domainObjectName="CustBasicInfoEntity" enableCountByExample="false"
           enableUpdateByExample="false" enableDeleteByExample="false"
           enableSelectByExample="false" selectByExampleQueryId="false" />
    <table tableName="cust_collection"
           domainObjectName="CustCollection" enableCountByExample="false"
           enableUpdateByExample="false" enableDeleteByExample="false"
           enableSelectByExample="false" selectByExampleQueryId="false" />
    <table tableName="cust_family_info"
           domainObjectName="CustFamilyInfoEntity" enableCountByExample="false"
           enableUpdateByExample="false" enableDeleteByExample="false"
           enableSelectByExample="false" selectByExampleQueryId="false" />
  </context>
</generatorConfiguration>

maven执行

新建maven工程
command line : mybatis-generator:generate -e

你可能感兴趣的:(IDEA配置mybatis-generator的maven启动方式)