使用Mybatis Generator插件自动生成映射文件

使用Mybatis Generator自动生成Mybatis所需要的Dao接口、实体模型类(po)、Mapping映射文件
有3种常用方法自动生成代码,命令行、eclipse插件、和Maven插件。
采用命令行自动生成的步骤如下
使用Mybatis Generator插件自动生成映射文件使用Mybatis Generator插件自动生成映射文件
配置文件源码

<?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:\generator\mysql-connector-java-5.1.8.jar"/>
    <context id="mysqlTables" targetRuntime="MyBatis3">
        <commentGenerator>
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <jdbcConnection 
        driverClass="com.mysql.jdbc.Driver"
        connectionURL="jdbc:mysql://localhost:3306/mydb?characterEncoding=utf8"
        userId="root" password="mysql">
        </jdbcConnection>
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>
        <javaModelGenerator targetPackage="com.po" targetProject="F:\generator\src">
            <property name="enableSubPackages" value="true"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>
        <sqlMapGenerator targetPackage="mybatis" targetProject="F:\generator\src">
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>
        <javaClientGenerator targetPackage="com.dao" type="XMLMAPPER" targetProject="F:\generator\src">
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>
        <table tableName="user" domainObjectName="User" enableCountByExample="false" 
        enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
        selectByExampleQueryId="false"/>
        
    
    </context>
    
  
</generatorConfiguration>

解码链接:https://www.cnblogs.com/dangzhenjiuhao/p/6679311.html
https://www.cnblogs.com/AryaZ/archive/2019/01/09/10245845.html

上一篇:Y7000 (1)安装ubuntu1604遇到的问题


下一篇:Hibarnate控制台打印不出sql,并且报出异常:org.hibernate.exception.JDBCConnectionException: Cannot open connection