Mybatis generator mapper文件覆蓋原文件的示例代碼
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> <properties resource='generator.properties'/> <context targetRuntime='MyBatis3' defaultModelType='flat'> <property name='beginningDelimiter' value='`'/> <property name='endingDelimiter' value='`'/> <property name='javaFileEncoding' value='UTF-8'/> <!-- 為模型生成序列化方法--> <plugin type='org.mybatis.generator.plugins.SerializablePlugin'/> <!-- 為生成的Java模型創(chuàng)建一個(gè)toString方法 --> <plugin type='org.mybatis.generator.plugins.ToStringPlugin'/> <!--生成mapper.xml時(shí)覆蓋原文件--> <plugin type='org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin' /> <!--配置數(shù)據(jù)庫連接--> <jdbcConnection driverClass='${jdbc.driverClass}' connectionURL='${jdbc.connectionURL}' userId='${jdbc.userId}' password='${jdbc.password}'> </jdbcConnection> <!--指定生成model的路徑--> <javaModelGenerator targetPackage='com.sw.model' targetProject='src/main/java'/> <!--指定生成mapper.xml的路徑--> <sqlMapGenerator targetPackage='com.sw.mbg.mapper' targetProject='src/main/resources'/> <!--指定生成mapper接口的的路徑--> <javaClientGenerator type='XMLMAPPER' targetPackage='com.sw.mbg.mapper'targetProject='src/main/java'/> <!--生成全部表tableName設(shè)為%--> <table tableName='user'> <generatedKey column='id' sqlStatement='MySql' identity='true'/> </table> </context></generatorConfiguration>
pom.xml引入依賴
<!-- MyBatis 生成器 --> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <!--依賴的版本要在1.3.5以上--> <version>1.3.7</version> </dependency>
到此這篇關(guān)于Mybatis generator mapper文件覆蓋原文件的文章就介紹到這了,更多相關(guān)Mybatis generator mapper文件內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. 什么是Access數(shù)據(jù)庫2. 使用Microsoft SQL Server 2000的XML查詢3. Microsoft Office Access添加字段的方法4. Microsoft Office Access添加頁眉或頁腳的方法5. MariaDB Spider 數(shù)據(jù)庫分庫分表實(shí)踐記錄6. Microsoft Office Access調(diào)整字段位置的方法7. mysql-bin.000001文件的來源及處理方法8. 傳甲骨文將增加對(duì)MySQL投資與微軟競(jìng)爭(zhēng)9. 經(jīng)驗(yàn):解決DB2中出現(xiàn)的SQL1032N錯(cuò)誤現(xiàn)象10. AIX環(huán)境下DB2許可證問題的解決方法及步驟
