一,引入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> <context id="MysqL" targetRuntime="MyBatis3Simple" defaultModelType="flat"> <property name="javaFileEncoding" value="UTF-8"/> <plugin type="tk.mybatis.mapper.generator.MapperPlugin"> <property name="mappers" value="com.example.ordersystem.common.mapper.SchoolBaseMapper"/> </plugin> <!-- 生成注释配置 --> <commentGenerator> <!-- 是否取消注释 --> <property name="suppressAllComments" value="false"/> <!-- 数据库注释支持 --> <property name="addRemarkComments" value="false"/> <!-- 时间格式设置 --> <property name="dateFormat" value="yyyy-MM-dd HH:mm:ss"/> </commentGenerator> <jdbcConnection driverClass="com.MysqL.jdbc.Driver" connectionURL="jdbc:MysqL://ip地址:3306/order_system?serverTimezone=GMT%2B8" userId="root" password="root"> </jdbcConnection> <javaModelGenerator targetPackage="com.example.ordersystem.common.entity" targetProject="src/main/java"/> <sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources"/> <javaClientGenerator targetPackage="com.example.ordersystem.common.mapper" targetProject="src/main/java" type="XMLMAPPER"/> <!-- <table tableName="t%" > <generatedKey column="id" sqlStatement="MysqL" identity="true" /> <domainObjectRenamingRule searchString="^T" replaceString="" /> <columnRenamingRule searchString="^T" replaceString=""/> </table>--> <table tableName="order_detail"> <generatedKey column="detail_id" sqlStatement="MysqL" identity="true"/> <domainObjectRenamingRule searchString="^T" replaceString=""/> <columnRenamingRule searchString="^T" replaceString=""/> </table> <table tableName="order_master"> <generatedKey column="order_id" sqlStatement="MysqL" identity="true"/> <domainObjectRenamingRule searchString="^T" replaceString=""/> <columnRenamingRule searchString="^T" replaceString=""/> </table> <table tableName="product_category"> <generatedKey column="category_id" sqlStatement="MysqL" identity="true"/> <domainObjectRenamingRule searchString="^T" replaceString=""/> <columnRenamingRule searchString="^T" replaceString=""/> </table> <table tableName="product_info"> <generatedKey column="product_id" sqlStatement="MysqL" identity="true"/> <domainObjectRenamingRule searchString="^T" replaceString=""/> <columnRenamingRule searchString="^T" replaceString=""/> </table> </context> </generatorConfiguration>
<plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version> 1.36</version> <configuration> <configurationFile>${basedir}/src/main/resources/generator/generatorConfiglocal.xml </configurationFile> <overwrite>true</overwrite> <verbose>true</verbose> </configuration> <dependencies> <dependency> <groupId>MysqL</groupId> <artifactId>mysql-connector-java</artifactId> <version>runtime</version> </dependency> <dependency> <groupId>tk.mybatis</groupId> <artifactId>mapper</artifactId> <version>3.4.6</version> </dependency> </dependencies> </plugin>