zoukankan      html  css  js  c++  java
  • springboot实现mybaitis逆向工程

    springboot实现mybaitis逆向工程

    1. 首先引入依赖,一共需要两个依赖(一个是mybaits依赖,一个是mybatis逆向工程插件)
    		<dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>2.1.3</version>
            </dependency>
            <!--   Mybatis逆向工程插件     -->
             <plugin>
                    <groupId>org.mybatis.generator</groupId>
                    <artifactId>mybatis-generator-maven-plugin</artifactId>
                    <version>1.3.7</version>
                    <configuration>
                        <overwrite>true</overwrite>                    										<configurationFile>
                        src/main/resources/generator/generatorConfig.xml
                        </configurationFile>
                    </configuration>
            </plugin>
    
    1. 然后在resource目录下新建generator文件夹,在generator文件夹创建一个generatorConfig.xml文件,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:LocalRepositorymysqlmysql-connector-java8.0.20mysql-connector-java-8.0.20.jar"/>
        <context id="DB2Tables" targetRuntime="MyBatis3">
            <commentGenerator>
                <property name="suppressDate" value="true"/>
                <!--   去除自动生成的注释         -->
                <property name="suppressAllComments" value="true"/>
            </commentGenerator>
            <!--数据库链接URL,用户名、密码 -->
            <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
                            connectionURL="jdbc:mysql://localhost:3306/fly?characterEncoding=UTF-8&amp;useSSL=true&amp;serverTimezone=UTC"
                            userId="root"
                            password="123">
            </jdbcConnection>
            <!-- 类型转换 -->
            <javaTypeResolver>
                <!-- 是否使用bigDecimal,
                    false: 把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer(默认)
                    true:  把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal
                -->
                <property name="forceBigDecimals" value="false"/>
            </javaTypeResolver>
            <!-- 生成模型的包名和位置-->
            <javaModelGenerator targetPackage="com.itguigu.demo1.bean" targetProject="src/main/java">
                <!-- 默认false 是否允许子包 -->
                <property name="enableSubPackages" value="true"/>
                <!-- 默认false 是否对类CHAR类型的列的数据进行trim操作 -->
                <property name="trimStrings" value="true"/>
            </javaModelGenerator>
            <!-- 生成映射文件的包名和位置-->
            <sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
                <property name="enableSubPackages" value="true"/>
            </sqlMapGenerator>
            <!-- 生成DAO的包名和位置-->
            <javaClientGenerator type="XMLMAPPER" targetPackage="com.itguigu.demo1.dao" targetProject="src/main/java">
                <property name="enableSubPackages" value="true"/>
            </javaClientGenerator>
            <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
            <!-- <table tableName="risk_model_order" domainObjectName="DSRiskModelOrder" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
             <table tableName="tel_bill_record" domainObjectName="DSTelBillRecord" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
            <table tableName="t_corp"
                   enableCountByExample="false"
                   enableUpdateByExample="false"
                   enableDeleteByExample="false"
                   enableSelectByExample="false"
                   selectByExampleQueryId="false">
            </table>
        </context>
    </generatorConfiguration>
    
    1. 点击右侧maven插件,生成mapper,dao,bean文件
  • 相关阅读:
    Suricata的输出
    Setting up IPS/inline for Linux in Suricata
    Suricata的初始化脚本
    Suricata的Reputation
    Suricata的配置
    Suricata的性能
    Suricata里的规则与Snort区别之处
    Suricata的命令行解释
    [转]ASP.NET 成员资格 Part.1(API)
    [转]ASP.NET MVC4+BootStrap 实战(一)
  • 原文地址:https://www.cnblogs.com/weixiao1717/p/14199087.html
Copyright © 2011-2022 走看看