itellij idea 11.1.3 mybatis automatically builds code

步骤一:
1、在工程中pom.xml加添
<build>
        <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>
    </build>

  2、在工程resources目录下添加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>
    <!-- database driver-->
    <!--<classPathEntry  location="mysql-connector-java-5.0.6-bin.jar"/>-->
    <classPathEntry  location="D:\MvnRepository\mysql\mysql-connector-java\5.1.6\mysql-connector-java-5.1.6.jar"/>
    <context id="default"  targetRuntime="MyBatis3">
        <commentGenerator>
            <property name="suppressDate" value="true"/>
            <!-- Whether to remove automatically generated comments true: yes: false: no -->
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <!--Database link URL, username, password-->
        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.1.11:3306/passport" userId="jshy" password="23DlwsxcdeJ32">
        </jdbcConnection>
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>
        <!-- The package name and location of the generated model -->
        <javaModelGenerator targetPackage="com.ppfuns.model" targetProject="src/main/java">
            <property name="enableSubPackages" value="true"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>
        <!-- Generate the package name and location of the mapping file-->
        <sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>
        <!-- Generate DAO package name and location-->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.ppfuns.dao" targetProject="src/main/java">
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>
        <!-- Which tables to generate -->
        <!--<table tableName="collect_lesson" domainObjectName="CollectLesson" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
        <!--<table tableName="lesson_classes" domainObjectName="LessonClasses" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->

        <!--<table tableName="pre_play_record" domainObjectName="PrePlayRecord" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
    </context>
</generatorConfiguration>
  

Command: mybatis-generator: generate -e

-Dmaven.multiModuleProjectDirectory=$M2_HOME


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326411444&siteId=291194637