mybatis鏈接mysql8.0以上版本數據庫的逆向工程配置


mybatis鏈接mysql8.0以上版本數據庫的逆向工程配置兩種xml文件配置方案:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
 3 <generatorConfiguration>
 4   <context id="context1">
 5    <!-- 注釋構建 -->
 6     <commentGenerator>
 7        <!-- 去掉所有的注釋 -->
 8         <property name="suppressAllComments" value="true"/>
 9         <property name="suppressDate" value="true"/>
10     </commentGenerator>
11     
12     <!-- 數據庫四要素 -->
13     <jdbcConnection connectionURL="jdbc:mysql://localhost:3306/gz_logistics?serverTimezone=UTC&amp;characterEncoding=utf-8&amp;useSSL=false" driverClass="com.mysql.cj.jdbc.Driver" password="myroot" userId="root" />
14     <!-- 實體類  -->
15     <javaModelGenerator targetPackage="top.abcdit.gzlogistics.pojo" targetProject="mybatis-generator/src" />
16     <!-- 映射文件 -->
17     <sqlMapGenerator targetPackage="top.abcdit.gzlogistics.mapper" targetProject="mybatis-generator/src" />
18     
19     <!-- ANNOTATEDMAPPER
20         XMLMAPPER
21      -->
22     
23     <!-- 操作接口 -->
24     <javaClientGenerator  targetPackage="top.abcdit.gzlogistics.mapper" targetProject="mybatis-generator/src" type="XMLMAPPER" />
25     <table  tableName="tb_user"  domainObjectName="Tb_user"  enableCountByExample="true" enableDeleteByExample="false" enableSelectByExample="true" enableUpdateByExample="false"></table>
26     <table  tableName="r_role" domainObjectName="R_role" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="true" enableUpdateByExample="false"></table>
27     <table  tableName="P_permission"  domainObjectName="P_permission" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="true" enableUpdateByExample="false"></table>
28   </context>
29 </generatorConfiguration>

或者

<?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>
  <context id="context1">
   <!-- 注釋構建 -->
    <commentGenerator>
       <!-- 去掉所有的注釋 -->
        <property name="suppressAllComments" value="true"/>
        <property name="suppressDate" value="true"/>
    </commentGenerator>
    
    <!-- 數據庫四要素 -->
    <jdbcConnection connectionURL="jdbc:mysql://localhost:3306/gz_logistics?useUnicode=true&amp;characterEncoding=utf-8&amp;serverTimezone=GMT&amp;nullCatalogMeansCurrent = true" 
      driverClass
="com.mysql.cj.jdbc.Driver" password="myroot" userId="root" /> <!-- 實體類 --> <javaModelGenerator targetPackage="top.abcdit.gzlogistics.pojo" targetProject="mybatis-generator/src" /> <!-- 映射文件 --> <sqlMapGenerator targetPackage="top.abcdit.gzlogistics.mapper" targetProject="mybatis-generator/src" /> <!-- ANNOTATEDMAPPER XMLMAPPER --> <!-- 操作接口 --> <javaClientGenerator targetPackage="top.abcdit.gzlogistics.mapper" targetProject="mybatis-generator/src" type="XMLMAPPER" /> <table tableName="tb_user" domainObjectName="Tb_user" enableCountByExample="true" enableDeleteByExample="false" enableSelectByExample="true" enableUpdateByExample="false"></table> <table tableName="r_role" domainObjectName="R_role" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="true" enableUpdateByExample="false"></table> <table tableName="P_permission" domainObjectName="P_permission" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="true" enableUpdateByExample="false"></table> </context> </generatorConfiguration>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM