springboot+tkmybatis 通用mapper 多模块逆向工程



generator.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>
    <!-- 引入 application.properties -->
    <properties resource="application1.properties"/>

    <!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
    <classPathEntry location="D:\Maven_repository\mysql\mysql-connector-java\8.0.16\mysql-connector-java-8.0.16.jar"/>

    <context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
        <property name="beginningDelimiter" value="`"/>
        <property name="endingDelimiter" value="`"/>
        <!-- <property name="javaFileEncoding" value="UTF-8"/>-->
        <!--        <property name="lombok" value="Getter,Setter,ToString,Accessors"/>-->

        <plugin type="tk.mybatis.mapper.generator.MapperPlugin">
            <property name="mappers" value="com.dingao.my.mapper.MyMapper"/>
            <property name="caseSensitive" value="true"/>
        </plugin>

        <!--数据库链接URL,用户名、密码 -->
        <jdbcConnection driverClass="${spring.datasource.driver-class-name}"
                        connectionURL="${spring.datasource.url}"
                        userId="${spring.datasource.username}"
                        password="${spring.datasource.password}">
        </jdbcConnection>

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

        <!-- 生成模型的包名和位置-->
        <javaModelGenerator targetPackage="com.dingao.pojo"
                            targetProject="F:\erp\dingao\dingao-pojo\src\main\java">
            <!-- <property name="enableSubPackages" value="false"/>
             <property name="trimStrings" value="false"/>-->
        </javaModelGenerator>
        <!-- 生成映射文件的包名和位置-->
        <sqlMapGenerator targetPackage="mapper"
                         targetProject="F:\erp\dingao\dingao-mapper\src\main\resources">
            <!-- enableSubPackages:是否让schema作为包的后缀 -->
            <!--        <property name="enableSubPackages" value="false" />-->
        </sqlMapGenerator>
        <!-- 生成DAO的包名和位置-->
        <javaClientGenerator type="XMLMAPPER"
                             targetPackage="com.dingao.mapper"
                             targetProject="F:\erp\dingao\dingao-mapper\src\main\java">
        </javaClientGenerator>
        <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
        <table tableName="allocation">
            <generatedKey column="id" sqlStatement="JDBC"/>
        </table>
        <table tableName="allocation_sku">
            <generatedKey column="id" sqlStatement="JDBC"/>
        </table>
    </context>
</generatorConfiguration>
pom 
```java
 <build>
        <plugins>
            <!-- mybatis 逆向工程maven工具, -->
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.6</version>
                <configuration>
                    <!--配置文件的路径 -->
                    <configurationFile>
                        src/main/resources/mybatis-generator.xml
                    </configurationFile>
                    <!-- 允许移动生成的文件 -->
                    <verbose>true</verbose>
                    <overwrite>true</overwrite>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>8.0.16</version>
                    </dependency>
                    <!-- 通用mapper逆向工具 -->
                    <dependency>
                        <groupId>tk.mybatis</groupId>
                        <artifactId>mapper</artifactId>
                        <version>3.5.3</version>
                    </dependency>
                </dependencies>

            </plugin>
        </plugins>
    </build>



已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页