使用 mybatis 自动生成mapper dao 和xml文件 导的包 generatorConfig配置

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:\Users\admin\.m2\repository\mysql\mysql-connector-java\5.1.39\mysql-connector-java-5.1.39.jar" />

    <context id="bid" targetRuntime="MyBatis3" defaultModelType="flat">

        <commentGenerator>
            <property name="suppressDate" value="true" />
            <!-- 是否去除自动生成的注释 true:是 : false:否 -->
            <property name="suppressAllComments" value="true" />
        </commentGenerator>
<!--        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test?characterEncoding=utf8&amp;useSSL=false" userId="root" password="root" />-->
        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://10.110.63.28:3306/iai?characterEncoding=utf8&amp;useSSL=false" userId="iai" password="123456a?" />

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

        <!-- 生成模型的包名和位置 -->
        <javaModelGenerator targetPackage="com.example.springboottest.model" targetProject="D:/project">
            <property name="enableSubPackages" value="false" />
            <property name="trimStrings" value="true" />
        </javaModelGenerator>

        <sqlMapGenerator targetPackage="/mybatis" targetProject="D:/project">
            <property name="enableSubPackages" value="false" />
        </sqlMapGenerator>

        <!-- 生成DAO的包名和位置 -->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.example.springboottest.dao" targetProject="D:/project">
            <property name="enableSubPackages" value="false" />
        </javaClientGenerator>


        <table schema="iai" tableName="t_news"
               enableCountByExample="false" enableUpdateByExample="false"
               enableDeleteByExample="false" enableSelectByExample="false"
               selectByExampleQueryId="false">
            <!--<property name="useActualColumnNames" value="false"/>-->

            <!-- 忽略列,不生成bean 字段
            <ignoreColumn column="FRED" />-->
            <!-- 指定列的java数据类型
            <columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" />-->
        </table>

    </context>
</generatorConfiguration>

 

对应 的 【pom.xml】

  <!-- mybatis 自动生成mapper dao 和xml文件 导的包-->
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.4</version>
                <configuration>
                    <!-- mybatis用于生成代码的配置文件 -->
                    <configurationFile>src/main/resources/mybatis-generator/generatorConfig.xml</configurationFile>
                    <verbose>true</verbose>
                    <overwrite>true</overwrite>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.44</version>
                    </dependency>
                </dependencies>
            </plugin>

 

上一篇:idea逆向工程配置


下一篇:mybatis逆向工程