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&characterEncoding=utf-8&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&characterEncoding=utf-8&serverTimezone=GMT&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>
原文地址:https://www.cnblogs.com/abcdjava/p/11198142.html
时间: 2024-10-06 13:09:46