tk-mybatis配置记录

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>
    <!--<properties resource="dev.properties"/>-->

    <context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
        <property name="beginningDelimiter" value="`"/>
        <property name="endingDelimiter" value="`"/>
        <property name="mergeable" value="false"></property>
        <plugin type="tk.mybatis.mapper.generator.MapperPlugin">
            <property name="mappers" value="tk.mybatis.mapper.common.Mapper"/>
        </plugin>

        <!--测试环境,查找keys:dev-->
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&amp;characterEncoding=UTF8&amp;allowMultiQueries=true&amp;serverTimezone=Asia/Shanghai&amp;useUnicode=true&amp;characterEncoding=utf-8"
                        userId="root"
                        password="123456">
        </jdbcConnection>


        <javaModelGenerator targetPackage="com.jayce.apiversion.common.entity"
                            targetProject="src/main/java/"/>

        <sqlMapGenerator targetPackage="com.jayce.apiversion.common.dao"
                         targetProject="src/main/resources/"/>

        <javaClientGenerator targetPackage="com.jayce.apiversion.common.dao"
                             targetProject="src/main/java/"
                             type="XMLMAPPER"/>

        <table tableName="library_book" domainObjectName="LibraryBook">
            <!--<property name="rootClass"
                      value="com.jayce.jcweb.common.book.vo.extra.LibraryBookExtra"/>-->
            <generatedKey column="book_id" identity="false" sqlStatement="MySql"/>
        </table>

        <!--示例说明-->
        <!--<table tableName="water_user_account" domainObjectName="WaterUserAccount">
                &lt;!&ndash; 继承基类 &ndash;&gt;
                <property name="rootClass" value="com.yc.cloud.water.common.base.entity.WaterBaseEntity"/>
                &lt;!&ndash; 主键设置 &ndash;&gt;
                <generatedKey column="user_account_id" identity="false" sqlStatement="MySql"/>
        </table>-->

    </context>
</generatorConfiguration>

pom文件关键代码

<!-- 通用mapper -->
        <dependency>
            <groupId>tk.mybatis</groupId>
            <artifactId>mapper-spring-boot-starter</artifactId>
            <version>1.1.2</version>
        </dependency>

<plugins>
            <!-- 此插件用来生成通用mapper的代码 -->
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.2</version>
                <configuration>
                    <configurationFile>./src/main/resources/generatorConfig.xml</configurationFile>
                    <overwrite>true</overwrite>
                    <verbose>true</verbose>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>8.0.13</version>
                        <scope>runtime</scope>
                    </dependency>
                    <dependency>
                        <groupId>tk.mybatis</groupId>
                        <artifactId>mapper</artifactId>
                        <version>3.4.0</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值