MyBatis Generator生成重複xml/Mapper對象解決方案

背景
其他詳細步驟這裏不做詳述,可以百度。

配置版本信息:
MBG:1.3.7
MYSQL 驅動:8.0.15

出問題的table標籤配置如下:

<table tableName="account" domainObjectName="Account"
       modelType="flat"
       enableCountByExample="false"
       enableUpdateByExample="false"
       enableDeleteByExample="false"
       enableSelectByExample="false"
       selectByExampleQueryId="false">
    <property name="useActualColumnNames" value="false"/>
</table>

執行MBG後,告警提示:

[WARNING] Table Configuration account matched more than one table (abc…account,xyz…account)

說明該數據庫連接下有兩個庫abc, xyz,裏面都有account表,需要指定是用哪一個庫,於是我在table標籤裏面添加上schema="abc",再次執行MBG提示:

[INFO] Saving file AccountMapper.xml
[INFO] Saving file AccountMapper.xml
[INFO] Saving file Account.java
[INFO] Saving file AccountMapper.java
[INFO] Saving file Account.java
[INFO] Saving file AccountMapper.java

說明在table裏面添加schema屬性後,指定使用哪一個庫壓根就沒有成功,依然會生成重複的文件。

解決

搜索了很久… 查詢各個配置還是得不到解決,最後嘗試將schema修改爲catalog後再次執行,只生成了一次文件,沒有再重複,問題解決

<table catalog="abc" tableName="account" domainObjectName="Account"
       modelType="flat"
       enableCountByExample="false"
       enableUpdateByExample="false"
       enableDeleteByExample="false"
       enableSelectByExample="false"
       selectByExampleQueryId="false">
    <property name="useActualColumnNames" value="false"/>
</table>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章