zoukankan      html  css  js  c++  java
  • 使用mysql驱动包8.0版本逆向工程时踩的坑

    逆向工程步骤:
    1.在pom.xml文件中引入 mybatis-generator插件
    <!-- mybatis逆向工程插件--> <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> <verbose>true</verbose> <overwrite>true</overwrite> </configuration> </plugin>
    2.配置generatorConfig.xml文件:
    `

        <plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin>
    
        <plugin type="org.mybatis.generator.plugins.ToStringPlugin"></plugin>
        <!--suppressAllComments 设置为true 则不再生成注释-->
        <commentGenerator>
            <property name="suppressDate" value="true"/>
            <property name="suppressAllComments" value="true" />
        </commentGenerator>
    
        <!-- 数据库的相关配置 -->
    
        <jdbcConnection
                driverClass="com.mysql.cj.jdbc.Driver"
                connectionURL="jdbc:mysql://localhost:3306/music?useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC"
                userId="root"
                password="root123456">
        </jdbcConnection>
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>
    
        <!-- 实体类生成的位置 -->
        <javaModelGenerator targetPackage="com.person.project.music.domain" targetProject="src/main/java">
            <!-- 是否允许子包,即targetPackage.schemaName.tableName -->
            <property name="enableSubPackages" value="true"/>
            <!-- 是否对model添加 构造函数 -->
            <property name="constructorBased" value="true"/>
            <!-- 是否对类CHAR类型的列的数据进行trim操作 -->
            <property name="trimStrings" value="true"/>
            <!-- 建立的Model对象是否 不可改变  即生成的Model对象不会有 setter方法,只有构造方法 -->
            <property name="immutable" value="false"/>
        </javaModelGenerator>
    
        <!-- Mapper.xml 文件的位置 -->
        <sqlMapGenerator targetPackage="mappers" targetProject="src/main/resources">
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>
    
        <!-- Mapper 接口文件的位置 -->
        <javaClientGenerator targetPackage="com.person.project.music.dao" targetProject="src/main/java" type="XMLMAPPER">
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>
    
        <!-- table指定每个生成表的生成策略  表名 和 model实体类名-->
        <table tableName="admin" domainObjectName="Admin"
               enableCountByExample="true" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
        <table tableName="collect" domainObjectName="Collect"
               enableCountByExample="true" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
        <table tableName="comment" domainObjectName="Comment"
               enableCountByExample="true" enableUpdateByExample="true"![](https://img2020.cnblogs.com/blog/1418975/202011/1418975-20201102195303064-1085587034.png)
    
    
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
        <table tableName="list_song" domainObjectName="Listsong"
               enableCountByExample="true" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
        <table tableName="singer" domainObjectName="Singer"
               enableCountByExample="true" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
        <table tableName="song" domainObjectName="Song"
               enableCountByExample="true" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
        <table tableName="song_list" domainObjectName="Songlist"
               enableCountByExample="true" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
        <table tableName="song_list_rank" domainObjectName="Songlistrank"
               enableCountByExample="true" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
    
        <table tableName="users" domainObjectName="Users"
               enableCountByExample="true" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
        </table>
    </context>
    
    ` **3.执行Maven中的mybatis-generate命令进行逆向生成**

    使用jdbc驱动 8.0最蛋疼的坑

    一定要配上如下配置,尤其是 jdbcUrl,一定要看清楚
    <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/music?useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC" userId="root" password="root123456"> </jdbcConnection>

    一路涉足、一路留恋、一路回望。依旧前行。
  • 相关阅读:
    WCF bindings comparison z
    DevExpress打印功能 z
    使用Topshelf 5步创建Windows 服务 z
    Log4net中的RollingFileAppender z
    Log4Net在Windows服务中不能记录日志 z
    dev 注册方法 z
    async callback z
    多窗体之间方法调用 z
    [JS6] 通过用户事件事件执行脚本
    [JS5] 利用onload执行脚本
  • 原文地址:https://www.cnblogs.com/yuxiangyuan-cloud/p/13916128.html
Copyright © 2011-2022 走看看