zoukankan      html  css  js  c++  java
  • SpringBoot + Mybaties的逆向工程有数据库生成domain的过程

    环境:  jdk1.8 (适合springboot2.X以上版本)

              Maven(3.3.X以上)

              spring boot 2.1.6

              Idea 2019.1

            


    这里随便填

      

    选择相应的Jar,如以下的勾选


    下面才是最重要的操作 ,在pom.xml里面导入mybaties逆向工程需要的jar,


    在pom.xml里面配置相应的所需要的代码,在这里我们单独出一个<plugle></plugle>,它跟之前的(idea自动生成的)是属于同一个评级上面.


    在 src/main/resources/的路径下面配置generatorConfig.xml  文件.  注意这里的数据库驱动是你电脑的硬盘上的或者说是你maven的仓库里面的

    <?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">
    <!--利用MyBatis Generator里面的Xml文件格式,复制成为resource的xml文件,并进行修改-->
    <generatorConfiguration>
        <!--找到MySQL驱动包的路径-->
        <classPathEntry location="E:maven
    epositorymysqlmysql-connector-java5.1.28mysql-connector-java-5.1.28.jar" />
        <!--配置连接MySQL数据库的信息-->
        <context id="inputdb" targetRuntime="MyBatis3">
            <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                            connectionURL="jdbc:mysql://localhost:3306/test"
                            userId="root"
                            password="root">
            </jdbcConnection>
            <!--会将数据库里的int类型数据转换为Java里的bigDecimals -->
            <javaTypeResolver >
                <property name="forceBigDecimals" value="false" />
            </javaTypeResolver>
            <!--配置各个文件的相对路径和项目路径-->
            <!--产生实体类,需要和App是同级的-->
            <javaModelGenerator targetPackage="com.kay.entity" targetProject="src/main/java">
                <property name="enableSubPackages" value="true" />
                <property name="trimStrings" value="true" />
            </javaModelGenerator>
            <!--映射文件,一定是在resources中的-->
            <sqlMapGenerator targetPackage="mapper"  targetProject="src/main/resources">
                <property name="enableSubPackages" value="true" />
            </sqlMapGenerator>
            <!--底层dao-->
            <javaClientGenerator type="XMLMAPPER" targetPackage="com.kay.dao"  targetProject="src/main/java">
                <property name="enableSubPackages" value="true" />
            </javaClientGenerator>
    
            <!--将example类型设为false,否则实体类里面会多一个example的类exampleStudent -->
            <!--表明为数据库的表明,生成实体类Student,会自动生成到entity的目录中-->
            <table tableName="user" domainObjectName="Area" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false">
            </table>
    
    
        </context>
    </generatorConfiguration>

     解释

    最后是生成过程


    有志者、事竟成,破釜沉舟,百二秦关终属楚; 苦心人、天不负,卧薪尝胆,三千越甲可吞吴. 加油吧,致每个正在奋斗路上的你!!!
  • 相关阅读:
    mysql启动报错:Failed to start LSB: start and stop MySQL
    springboot学习源码
    A query was run and no Result Maps were found for the Mapped Statement
    mybaties报错:There is no getter for property named 'table' in 'class java.lang.String'
    redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set
    Missing artifact com.lowagie:itextasian:jar:2.1.7
    Vue.js安装及环境搭建
    高并发与多线程
    NoNodeAvailableException[None of the configured nodes are available:[.127.0.0.1}{127.0.0.1:9300]
    oracle中sys用户下all_tables表个字段说明
  • 原文地址:https://www.cnblogs.com/cb1186512739/p/11157759.html
Copyright © 2011-2022 走看看