解决Mybatis generator使用suppressAllComments去除掉注释后的影响(mapper.xml)会变重复

解决Mybatis generator使用suppressAllComments去除掉注释后的影响(mapper.xml)会变重复
解决Mybatis generator使用suppressAllComments去除掉注释后的影响(mapper.xml)会变重复_第1张图片
mybatis generator的帮助文档中也指出了使用suppressAllComments去掉注释之后可能会出现这种错误

插件版本1.3.7

<build>
        <plugins>
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.7</version>
                <configuration>
                    <!--配置文件的位置-->
                    <configurationFile>src/main/resources/generaterConfig.xml</configurationFile>
                    <verbose>true</verbose>
                    <overwrite>true</overwrite>
                </configuration>
            </plugin>
        </plugins>
    </build>

pom.xml

		
        
            org.mybatis.generator
            mybatis-generator-core
            1.3.7
        

这是没加上处理后的样子,mapper文件中重复非常多
解决Mybatis generator使用suppressAllComments去除掉注释后的影响(mapper.xml)会变重复_第2张图片

我们在generator.xml文件中加入

<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />
<generatorConfiguration>
    <classPathEntry location="/Users/server/Repository/mysql/mysql-connector-java/8.0.18/mysql-connector-java-8.0.18.jar"/>
	.....
    <context id="DB2Tables" targetRuntime="MyBatis3">
        <!--覆盖生成XML文件-->
        <plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />
        <commentGenerator>
        <!-- 不生成注释 -->
                <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        .....
     </context>
</generatorConfiguration>

再次自动生成代码会发现mapper文件中代码重复的问题已经解决,其他类中的代码也干净了许多
解决Mybatis generator使用suppressAllComments去除掉注释后的影响(mapper.xml)会变重复_第3张图片

你可能感兴趣的:(解决Mybatis generator使用suppressAllComments去除掉注释后的影响(mapper.xml)会变重复)