mybatis 自动生成文件配置
maven 依赖配置:
<!-- sql server -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.4</version>
</dependency> <dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency> 构建所需插件
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
<!-- mybatis generator 自动生成代码插件 -->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.6.1</version>
</plugin>
</plugins>
<finalName>springboot-test</finalName>
<!-- 指定生成文件存放的目录 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>application.properties</include>
<include>banner.txt</include>
<include>META-INF/app.properties</include>
<!--<include>application-${profileActive}.properties</include>-->
</includes>
<excludes>
<exclude>generatorConfig.xml</exclude>
</excludes>
</resource>
</resources>
</build> generatorConfig.xml文件配置,该文件在resource目录下。
<?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>
<!-- 修改成自己本地的maven仓库地址,只需要替换红色部分即可(D:\maven\repository) -->
<classPathEntry location="D:\maven\repository\com\microsoft\sqlserver\mssql-jdbc\6.1.0.jre8\mssql-jdbc-6.1.0.jre8.jar" />
<context defaultModelType="flat" id="write" targetRuntime="MyBatis3">
<plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>
<plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
<commentGenerator>
<property name="suppressAllComments" value="false"/>
<property name="suppressDate" value="false"/>
</commentGenerator>
<!-- 这里是sqlserver 数据库 -->
<jdbcConnection driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"
connectionURL="jdbc:sqlserver://ip:1433;DatabaseName=test"
userId="sa"
password="123456">
</jdbcConnection> <javaTypeResolver>
<property name="trimStrings" value="true" />
<property name="forceBigDecimals" value="false" />
</javaTypeResolver> <!--生成model 指定生成后类的存放目录-->
<javaModelGenerator targetPackage="com.example.model.po.base.mbg"
targetProject="${generator.path}/src/main/java">
<property name="enableSubPackages" value="true"/>
</javaModelGenerator> <!--生成xml文件 指定生成后的xml 文件存放的目录-->
<sqlMapGenerator targetPackage="com.example.dal.mappers.base.mbg"
targetProject="${generator.path}/src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</sqlMapGenerator> <!--生成mappers 指定生成 后mappers 接口存放的目录-->
<javaClientGenerator targetPackage="com.example.dal.dao.base.mbg"
targetProject="${generator.path}/src/main/java"
type="XMLMAPPER">
<property name="enableSubPackages" value="true"/>
<property name="exampleMethodVisibility" value="public"/>
<property name="methodNameCalculator" value="default"/>
</javaClientGenerator> <!-- tableName:指的是你数据库中表的名称;domainObjectName:指的是生成实体类对应的名称 -->
<table tableName="SYS_Menu" domainObjectName="SysMenu" enableSelectByPrimaryKey="true" enableCountByExample="true" enableSelectByExample="true">
<property name="useActualColumnNames" value="true" />
<!-- column:指的是sql语句是否设置自动增长 -->
<generatedKey column="id" identity="true" sqlStatement="SqlServer"/>
</table> </context>
</generatorConfiguration>
mybatis 自动生成文件配置的更多相关文章
- mybatis generator配置,Mybatis自动生成文件配置,Mybatis自动生成实体Bean配置
mybatis generator配置,Mybatis自动生成文件配置,Mybatis自动生成实体Bean配置 ============================== 蕃薯耀 2018年3月14 ...
- Mybatis自动生成的配置实例
一.目录 按照图片准备下面的东西吧,基础jar,数据链接库的jar. 二.generatorConfig.xml <?xml version="1.0" encoding=& ...
- mybatis自动生成model、dao及对应的mapper.xml文件
背景: 日常开发中,如果新建表,手动敲写model.dao和对应的mapper.xml文件,费时费力且容易出错, 所以采用mybatis自动生成model.dao及对应的mapper.xml文件.代码 ...
- springboot整合mybatis,利用mybatis-genetor自动生成文件
springboot整合mybatis,利用mybatis-genetor自动生成文件 项目结构: xx 实现思路: 1.添加依赖 <?xml version="1.0" e ...
- mybatis自动生成java代码
SSM框架没有DB+Record模式,写起来特别费劲,只能用下面的方法勉强凑合. 上图中,*.jar为下载的,src为新建的空白目录,.xml配置如下. <?xml version=" ...
- Mybatis自动生成实体类
Maven自动生成实体类需要的jar包 一.pom.xml中 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns ...
- 使用mybatis-generator插件结合tk.mybatis自动生成mapper二三事
本篇文章将介绍使用spring boot框架,引入mybatis-generator插件,结合tk.mybatis自动生成Mapper和Entity的一整套流程,其中包括最重要的踩坑与填坑. ...
- mybatis自动生成代码插件mybatis-generator使用流程(亲测可用)
mybatis-generator是一款在使用mybatis框架时,自动生成model,dao和mapper的工具,很大程度上减少了业务开发人员的手动编码时间 坐着在idea上用maven构建spri ...
- 使用mybatis-generator插件结合tk.mybatis自动生成mapper
本篇文章将介绍使用spring boot框架,引入mybatis-generator插件,结合tk.mybatis自动生成Mapper和Entity的一整套流程,其中包括最重要的踩坑与填坑. ...
随机推荐
- Spring Cloud Config采坑记
1. Spring Cloud Config采坑记 1.1. 问题 在本地运行没问题,本地客户端服务能连上本地服务端服务,可一旦上线,发现本地连不上线上的服务 服务端添加security登录加密,客户 ...
- ubuntu ImageMagick 图像转换工具
ImageMagick(简称 IM)是一个支持 GPL 协议的开源免费软件包.它由一组命令行工具组成的.它可以对超过 100 种的图像格式(包括 DPX, EXR, GIF, JPEG, JPEG-2 ...
- [工具]K8tools github/K8工具合集/K8网盘
K8tools 20190428 声明: 工具仅供安全研究或授权渗透,非法用途后果自负. 博客: https://www.cnblogs.com/k8gege 下载: https://github.c ...
- ES6 块级作用域
作用域包括:全局作用域,函数作用域,块级作用域. 为什么要用块级作用域: 1.内层变量可能会覆盖外层变量. var name = "kevin"; function call() ...
- mysql 开发基础系列13 选择合适的数据类型(下)
一. BloB和Text 1. 合成索引 合成索引可以提高大文本字段BLOB和Text的查询性能, 合成索引是在表中增加一个字段存放散列值,这种技术只能用于精确匹配的查询,可以使用md5()或sha ...
- springboot与ActiveMQ整合
前言 很多项目, 都不是一个系统就做完了. 而是好多个系统, 相互协作来完成功能. 那, 系统与系统之间, 不可能完全独立吧? 如: 在学校所用的管理系统中, 有学生系统, 资产系统, 宿舍系统等等. ...
- 【原创】Git 分支的合并【Learn Git Branching】
merge git merge是我们要学习的合并工作的第一个方法.合并产生一个特殊的提交记录,它包含两个唯一父提交.有两个父提交的提交记录本质上是:“我想把这两个父提交本身及它们的父提交集 ...
- go跨平台编译
go语言支持直接编译不同系统的可执行程序,例如可以直接在mac上可以直接编译linux的执行程序 支持的环境变量 GOOS:目标可执行程序运行操作系统,支持 darwin,freebsd,linux, ...
- HTTP协议学习(一)
一.HTTP报文的组成 请求报文由 请求行.请求头.请求空行.请求实体四部分组成.其中,请求行和请求头共同组成 请求报文头部 请求行:一行,依次由 请求方法.URI(或者应该说是域名?).HTTP协议 ...
- Python 的 setitem、getitem、delitem 特殊方法使用
简介 setitem:当属性被以索引方式赋值的时候会调用该方法 getitem:一般如果想使用索引访问元素时,就可以在类中定义这个方法 delitem:当使用索引删除属性时调用该方法 实例 __Aut ...