首页 > 其他 > 详细

Mybatis引用Generator插件

时间:2021-01-31 23:59:53      阅读:44      评论:0      收藏:0      [点我收藏+]
<?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">

<!-- mybatis generator文档地址:http://mybatis.org/generator/index.html -->
<generatorConfiguration>
<!-- 数据库配置文件地址 -->
<properties resource="application.properties"/>
<!-- id为项目名 -->
<context id="my-blog" targetRuntime="MyBatis3">

<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>

<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="${spring.datasource.driverClassName}"
connectionURL="${spring.datasource.url}" userId="${spring.datasource.username}" password="${spring.datasource.password}">
</jdbcConnection>

<!-- 数据类型转换 -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>

<!-- 生成模型的包名和位置,按照项目实际情况修改 -->
<javaModelGenerator targetPackage="com.site.blog.my.core.entity"
targetProject="src/main/java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="true"/>
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true"/>
</javaModelGenerator>

<!-- 生成XML映射文件的包名和位置,按照项目实际情况修改 -->
<sqlMapGenerator targetPackage="mapper"
targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>

<!-- 生成DAO的包名和位置 ,按照项目实际情况修改-->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.site.blog.my.core.dao"
targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>

<!-- 要生成哪些表,可以有多个table元素 -->
<!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 -->
<!-- 默认设置会生成一大堆罗哩罗嗦的Example类,主要是用各种不同的条件来操作数据库,大部分是用不到的-->
        <table schema = "my_blog_db" tableName="tb_blog_category"
domainObjectName="BlogCategory"
enableCountByExample= "false"
enableUpdateByExample= "false"
enableDeleteByExample= "false"
enableSelectByExample= "false"
selectByExampleQueryId= "false">
</table>
</context>
</generatorConfiguration>

Mybatis引用Generator插件

原文:https://www.cnblogs.com/sfnz/p/14354515.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!