利用Maven逆向工程生成mybatis映射文件

一,pom.xml

注意修改逆向工程配置文件的路徑

<build><pluginManagement><plugins><plugin><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-maven-plugin</artifactId><version>1.3.2</version><dependencies><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.35</version></dependency></dependencies><configuration><!--配置文件的路徑 --><configurationFile>src/main/resources/generatorConfig.xml</configurationFile><overwrite>true</overwrite></configuration></plugin></plugins></pluginManagement></build>

二,修改generatorConfig.xml文件

注意修改數據庫連接的URL,用戶名、密碼,修改生成model的位置,修改生成mapping文件的位置,修改哪些表需要逆向

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfigurationPUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN""http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration><context id="test" targetRuntime="MyBatis3"><plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin"></plugin><plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin><plugin type="org.mybatis.generator.plugins.ToStringPlugin"></plugin><commentGenerator><!-- 這個元素用來去除指定生成的注釋中是否包含生成的日期 false:表示保護 --><!-- 如果生成日期,會造成即使修改一個字段,整個實體類所有屬性都會發生變化,不利于版本控制,所以設置為true --><property name="suppressDate" value="true" /><!-- 是否去除自動生成的注釋 true:是 : false:否 --><property name="suppressAllComments" value="true" /></commentGenerator><!--數據庫鏈接URL,用戶名、密碼 --><jdbcConnection driverClass="com.mysql.jdbc.Driver"connectionURL="jdbc:mysql://localhost:3306/springbootdb?useUnicode=true&amp;characterEncoding=utf8" userId="root"password="a123"></jdbcConnection><javaTypeResolver><!-- This property is used to specify whether MyBatis Generator shouldforce the use of java.math.BigDecimal for DECIMAL and NUMERIC fields, --><property name="forceBigDecimals" value="false" /></javaTypeResolver><!-- 生成模型的包名和位置 --><javaModelGenerator targetPackage="org.cc.bean"targetProject="src/main/java"><property name="enableSubPackages" value="true" /><property name="trimStrings" value="true" /></javaModelGenerator><!-- 生成映射文件的包名和位置 --><sqlMapGenerator targetPackage="mapping"targetProject="src/main/resources"><property name="enableSubPackages" value="true" /></sqlMapGenerator><!-- 生成DAO的包名和位置 --><javaClientGenerator type="XMLMAPPER"targetPackage="org.cc.dao"targetProject="src/main/java"><property name="enableSubPackages" value="true" /></javaClientGenerator><!-- 要生成哪些表 --><table tableName="`goods`" domainObjectName="Goods" enableCountByExample="false"enableUpdateByExample="false" enableDeleteByExample="false"enableSelectByExample="false" selectByExampleQueryId="false"><generatedKey column="id" sqlStatement="Mysql" identity="true"/></table></context>
</generatorConfiguration>

三,使用maven生成model和mapping

選中項目》右鍵RunAs》輸入mybatis-generator:generate

刷新目錄可以看到生了bean,dao和mapping文件

注意再次執行會在mapping文件后面添加內容,會重復,所以再次執行前先將mapping文件刪除。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/530345.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/530345.shtml
英文地址,請注明出處:http://en.pswp.cn/news/530345.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

mysql update多個表_mysql update 多表 (復制)

定我們有兩張表&#xff0c;一張表為Product表存放產品信息&#xff0c;其中有產品價格列Price&#xff1b;另外一張表是ProductPrice表&#xff0c;我們要將ProductPrice表中的價格字段Price更新為Price表中價格字段的80%。在Mysql中我們有幾種手段可以做到這一點&#xff0c;…

ORA-00907:missing right parenthesis缺少右括號

一&#xff0c;有嵌套查詢&#xff0c;并且子查詢中用了union all合并兩個查詢時&#xff0c;前一個查詢用了order by&#xff0c;那么會報錯并提示ORA-00907:missing right parenthesis缺少右括號&#xff1a; select * from ( select t.* from emp t where t.jobMANAGER ord…

mysql重復記錄大于十的數據庫_面試官:在使用mysql數據庫時,遇到重復數據怎么處理?...

前言前段時間&#xff0c;很多人問我能不能寫一些數據庫的文章&#xff0c;正好自己在測試mysql數據庫性能的時候&#xff0c;出現了一個問題&#xff0c;也就是出現了很多重復的數據&#xff0c;想起來自己long long ago寫過一篇類似的&#xff0c;僅此就拿來總結了一下。如果…

線程組的概念

一&#xff0c;線程組和線程的結構&#xff1a;樹形結構 每個Thread必然存在于一個ThreadGroup中&#xff0c;Thread不能獨立于ThreadGroup存在。 執行main()方法線程的名字是main 如果在new Thread時沒有顯式指定&#xff0c;那么默認將父線程&#xff08;當前執行new Threa…

mysql中ak替換鍵_數據庫:唯一性約束_alternate key(替換鍵) mySQL Oracle 數據庫 ak 唯一性約束...

數據庫:唯一性約束_alternate key(替換鍵) mySQL Oracle 數據庫 ak 唯一性約束數據庫:唯一性約束所謂唯一性約束(unique constraint)不過是數據表內替代鍵的另一個名稱而已。替代鍵(alternate key)可以是數據表內不作為主鍵的其他任何列&#xff0c;只要該鍵對該數據表唯一即可…

Oracle自定義類型

Oracle自定義類型可以通過type/create type來聲明或者創建 一&#xff0c;四種創建方式 1.1&#xff0c;使用create type創建object類型 create or replace type obj_type as object(id number,name varchar2(50 byte),birthday date); 1.2&#xff0c;使用create type創建…

Oracle/mysql查詢語句的執行過程

執行順序 from on join/pivot/unpivot(mysql沒有pivot和unpivot) where group by having select distinct order by limit&#xff08;oralce沒有&#xff09; 書寫順序 select distinct <select_list> from <left_table> <join_type>join <righ…

mysql定時sql腳本_定時執行的SQL腳本

因為要同步一個表&#xff0c;所以每天要同步一次數據&#xff0c;但是對SQL不是精通的我&#xff0c;為了測試寫了一段代碼來測試定時功能創建一個存儲過程&#xff0c;是用來插數據的&#xff0c;沒有輸出和輸出參數create or replace procedure temp_pro asbegininsert into…

mysql xml語句_Mysql語句

xml文件轉義字符處理(1)(2)直接寫轉義后的字符1、mysql里批量修改表內某個字段內的部分數據UPDATE inventory_stockSET batchno REPLACE(batchno,-20-201901,-50-2019)2、ON DUPLICATE KEY UPDATE根據主鍵判斷是新增還是修改(也可以有兩個或多個主鍵)INSERT INTO TABLE (a,c) …

destoon網站mysql分表_destoon : 常用數據庫操作

destoon在初始化系統后系統會自動連接數據庫&#xff0c;并將數據庫操作對象保存在$db。對于數據庫操作方法參考include/db_mysql.class.php函數原型&#xff0c;我來寫幾個常用數據庫操作。1、讀取單條信息$S $db->get_one("SELECT * FROM {$DT_PRE}table WHERE xxxy…

delphi7 mysql控件_Delphi7連接MySql數據庫-DBGrid控件顯示數據

一個簡單的Delphi7小程序&#xff0c;使用MySql數據庫做簡單查詢&#xff0c;用DBGrid控件顯示結果&#xff0c;實現過程如下&#xff1a;(1)在MySql中新建demouser表&#xff0c;插入記錄用于測試。(2)在Delphi7中新建項目。(3)在From中添加組件。組件Panel&#xff1a;pnl1組…

for循環false 終止 python_python3.5.1給用戶3次無效的嘗試,然后終止pgm(Simple FOR循環)...

我需要幫助(新生-2周)。我想得到這段代碼可能的最微小的變化&#xff0c;允許用戶3次在程序中輸入錯誤的值。輸入錯誤值3次后&#xff0c;程序應終止。唯一的要求是代碼必須包含FOR循環。我不知道它是需要一個FOR循環還是3個FOR循環(每次轉換一個)。我嘗試了很多種方案&#xf…

mysql何時會走索引

訪問類型&#xff0c;這里只列出最常見的6種類型 all,index,range,ref,eq_ref&#xff0c;const mysql中explain的type的解釋_dennis211的博客-CSDN博客_explain type 使用不同的運算符時訪問類型不一樣&#xff1a; !、not in、<>、>、<、in(多個值)、or、bet…

mysql數據庫唯一性_在MySQL數據庫中添加唯一性約束,范圍可能嗎?

我有一個使用MySQL的Rails應用程序。我在兩個模型之間有一個has_many :through關聯&#xff0c;如下所述&#xff1a;class Category < ActiveRecord::Basehas_many :category_pairingshas_many :dishes, through: :category_pairings, :inverse_of > :categoriesendclas…

filtic函數 matlab_matlab filtic 函數應用 filter 解差分方程 dft 函數

matlab filtic 函數應用 filter 解差分方程 dft 函數一、 解差分方程說明都在代碼注釋里面了%這里要利用filtic函數 為濾波器的直接II型實現選擇初始條件%求解查分方程 y(n) - 0.4y(n-1) - 0.45y(n-2) 0.45x(n) 0.4x(n-1) - x(n-2)%y(-1) 0 y(-2) 1 x(-1) 1 x(-2) 2%x(n)…

rabbitmq進階一

上一篇文章有講到rabbitmq的安裝、web管理端和springboot簡單集成rabbitmq 本文重點介紹rabbitmq相關api的使用 按照官網常用的五種模式的順序&#xff1a;HelloWorld、Work queues、Publish/Subscribe、Routing、Topics 模式簡單介紹 HelloWorld 一個生產者&#xff0c;一…

mysql 相關搜索_MySQL單詞搜索相關度排名

一個單詞搜索的相關度排名,這個例子演示了一個單詞搜索的相關度排名計算。mysql> CREATE TABLE articles (-> id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,-> title VARCHAR(200),-> body TEXT,-> FULLTEXT (title,body)-> ) ENGINEInnoDB;Query O…

IDEA使用總結

idea中使用tomcat IntelliJ IDEA配置Tomcat&#xff08;完整版圖文教程&#xff09;_猿Bug的博客-CSDN博客_intellij tomcat配置 用上面的方式發現缺少文件&#xff0c;在edit configuration頁面選擇before lanuch前選擇Run maven goal package

mysql一直copying to tmp table_mysql提示Copying to tmp table on disk

網站運行的慢了&#xff0c;查找原因是Copying to tmp table on disk那怎么解決這個問題呢解決一例最近常常碰到網站慢的情況&#xff0c;登陸到后臺&#xff0c;查詢一下 /opt/mysql/bin/mysqladmin processlist;發現一個查詢狀態為&#xff1a; Copying to tmp table 而且此查…

idea cloud bootstrap是啥_application.yml與bootstrap.yml的區別

Spring Boot 默認支持 properties(.properties) 和 YAML(.yml .yaml ) 兩種格式的配置文件&#xff0c;yml 和 properties 文件都屬于配置文件&#xff0c;功能一樣。Spring Cloud 構建于 Spring Boot 之上&#xff0c;在 Spring Boot 中有兩種上下文&#xff0c;一種是 bootst…