您好,登錄后才能下訂單哦!
一、Maven配置文件中添加如下依賴
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
</dependency>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.4</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
</dependencies>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
<configurationFile>${basedir}/src/main/resources/generatorConfig.xml</configurationFile>
</configuration>
</plugin>
二、添加generatorConfig.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 >
<!-- mysql jar 文件位置 -->
<classPathEntry location="F:/instrument\maven/.m2/repository/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar" />
<context id="store" targetRuntime="MyBatis3">
<commentGenerator>
<!-- 是否去除自動生成的注釋 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
<!-- 是否去除所有自動生成的文件的時間戳,默認為false -->
<!-- <property name="suppressDate" value="false"/> -->
</commentGenerator>
<!--數據庫連接的信息:驅動類、連接地址、用戶名、密碼 -->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/g"
userId="root"
password="root">
<!--<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://112.35.82.91:3360/benevolenceParking"
userId="renrenbang"
password="05377975333">-->
</jdbcConnection>
<!-- targetPackage:包名稱(自定義) targetProject:項目路徑(自定義) -->
<javaModelGenerator targetPackage="com.zblx.park.po" targetProject="src/main/java">
<!-- enableSubPackages:是否讓schema作為包的后綴 -->
<property name="enableSubPackages" value="false" />
<!-- 從數據庫返回的值被清理前后的空格 -->
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- 配置生成相應的實體Mapper.xml,對于Mapper3.X我們需要把type="XMLMAPPER" -->
<!-- targetPackage:包名稱(自定義) targetProject:項目路徑(自定義) -->
<sqlMapGenerator targetPackage="com.zblx.park.mapper" targetProject="src/main/java">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!-- 配置生成相應的接口類,對應與Mapper.xml中的一系列CRUD方法SQL語句 -->
<!-- targetPackage:包名稱(自定義) targetProject:項目路徑(自定義) -->
<javaClientGenerator targetPackage="com.zblx.park.dao" targetProject="src/main/java" type="XMLMAPPER">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!-- 用戶表-->
<!--<table schema="benevolenceParking" tableName="parking" domainObjectName="Parking"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
>-->
<table schema="fruit" tableName="parking" domainObjectName="Parking"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
/>
<table schema="fruit" tableName="orders" domainObjectName="Orders"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
>
</table>
<table schema="fruit" tableName="car" domainObjectName="Car"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
>
</table>
<table schema="fruit" tableName="carlock" domainObjectName="CarLock"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
>
</table>
</context>
</generatorConfiguration>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。