草稿

1.在pom.xml中引入mybatis自动生成代码插件

    <build>
        <plugins>
            <!-- mybatis generator 自动生成代码插件 -->
            <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.

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
            location="F:\apache-maven-3.5.0\LocalMavenRepository\mysql\mysql-connector-java\5.1.38\mysql-connector-java-5.1.38.jar" />
    <context id="context1">
        <commentGenerator>
            <property name="suppressAllComments" value="true" /><!-- 是否取消注释 -->
            <property name="suppressDate" value="true" /> <!-- 是否生成注释代时间戳 -->
        </commentGenerator>
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/jianwu" userId="qukan"
                        password="quk_live123" />
        <!-- 实体-->
        <javaModelGenerator targetPackage="com.jianwu.win.entity"
                            targetProject="F:\jianwutest\Win\src\main\java\" />
        <!--mapper.xml-->
        <sqlMapGenerator targetPackage="com.jianwu.win.dao"
                         targetProject="F:\jianwutest\Win\src\main\java\" />
        <!--mapper.java-->
        <javaClientGenerator targetPackage="com.jianwu.win.dao"
                             targetProject="F:\jianwutest\Win\src\main\java\" type="XMLMAPPER" />

        <table schema="jianwu" tableName="user"
               enableCountByExample="false" enableSelectByExample="false"
               enableDeleteByExample="false" enableUpdateByExample="false">
        </table>

    </context>
</generatorConfiguration>

然后刷新下就会出现

双击生成代码

 

posted @ 2018-08-15 15:53  ENU  阅读(176)  评论(0编辑  收藏  举报