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模型创建一个toString方法 --> <plugin type='org.mybatis.generator.plugins.ToStringPlugin'/> <!--生成mapper.xml时覆盖原文件--> <plugin type='org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin' /> <!--配置数据库连接--> <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设为%--> <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>
到此这篇关于Mybatis generator mapper文件覆盖原文件的文章就介绍到这了,更多相关Mybatis generator mapper文件内容请搜索好吧啦网以前的文章或继续浏览下面的相关文章希望大家以后多多支持好吧啦网!
相关文章: