mybatis-generator逆向工程设置不生成Example类
2018-01-01 15:40
344 查看
之前每次生成 po 和 mapper,都会生成 Example 类和其对应的 CURD方法。删起来也比较麻烦,所以干脆让它不生成即可。
具体配置很简单,只需要在要设置的表的 table 标签里将要生成的方法给关掉即可,代码如下。
<table tableName="user"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
最后附上完整的 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>
<context id="testTables" targetRuntime="MyBatis3">
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/forest_blog?tinyInt1isBit=false" userId="root"
password="">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- targetProject:生成PO类的位置,重要!! -->
<javaModelGenerator targetPackage="com.liuyanzhao.blog.po"
targetProject="myGenerator/src">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- targetProject:mapper映射文件生成的位置,重要!! -->
<sqlMapGenerator targetPackage="com.liuyanzhao.blog.mapper"
targetProject="myGenerator/src">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!-- targetPackage:mapper接口生成的位置,重要!! -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.liuyanzhao.blog.mapper"
targetProject="myGenerator/src">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!-- 指定数据库表,要生成哪些表,就写哪些表,要和数据库中对应,不能写错! -->
<table tableName="user"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table tableName="article"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
</context>
</generatorConfiguration>
更多文章:mybatis逆向工程利用mybatis-generator-core自动生成代码
本文链接:https://liuyanzhao.com/6207.html
具体配置很简单,只需要在要设置的表的 table 标签里将要生成的方法给关掉即可,代码如下。
<table tableName="user"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
最后附上完整的 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>
<context id="testTables" targetRuntime="MyBatis3">
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/forest_blog?tinyInt1isBit=false" userId="root"
password="">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- targetProject:生成PO类的位置,重要!! -->
<javaModelGenerator targetPackage="com.liuyanzhao.blog.po"
targetProject="myGenerator/src">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- targetProject:mapper映射文件生成的位置,重要!! -->
<sqlMapGenerator targetPackage="com.liuyanzhao.blog.mapper"
targetProject="myGenerator/src">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!-- targetPackage:mapper接口生成的位置,重要!! -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.liuyanzhao.blog.mapper"
targetProject="myGenerator/src">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!-- 指定数据库表,要生成哪些表,就写哪些表,要和数据库中对应,不能写错! -->
<table tableName="user"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table tableName="article"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
</context>
</generatorConfiguration>
更多文章:mybatis逆向工程利用mybatis-generator-core自动生成代码
本文链接:https://liuyanzhao.com/6207.html
相关文章推荐
- 在IDEA中使用MyBatis Generator逆向工程生成代码 实践
- idea中使用MyBatis Generator逆向工程生成代码
- mybatis generator逆向工程生成一对多映射
- IDEA mybatis-generator逆向工程生成代码
- Mybatis在IDEA中使用generator逆向工程生成pojo,mapper
- 在使用Mybatis框架的JavaWeb项目中通过Mybatis Generator逆向工程自动生成Java类文件
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- mybatis-generator逆向生成工程代码
- 【MyBatis学习15】mybatis-generator生成逆向工程两种方式
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- Mybatis在IDEA中使用generator逆向工程生成pojo,mapper
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- mybatis逆向工程生成的Example类的使用
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- mybatis-generator生成逆向工程两种方式
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- 在IDEA中使用MyBatis Generator逆向工程生成代码