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 自动生成文件配置的更多相关文章

  1. mybatis generator配置,Mybatis自动生成文件配置,Mybatis自动生成实体Bean配置

    mybatis generator配置,Mybatis自动生成文件配置,Mybatis自动生成实体Bean配置 ============================== 蕃薯耀 2018年3月14 ...

  2. Mybatis自动生成的配置实例

    一.目录 按照图片准备下面的东西吧,基础jar,数据链接库的jar. 二.generatorConfig.xml <?xml version="1.0" encoding=& ...

  3. mybatis自动生成model、dao及对应的mapper.xml文件

    背景: 日常开发中,如果新建表,手动敲写model.dao和对应的mapper.xml文件,费时费力且容易出错, 所以采用mybatis自动生成model.dao及对应的mapper.xml文件.代码 ...

  4. springboot整合mybatis,利用mybatis-genetor自动生成文件

    springboot整合mybatis,利用mybatis-genetor自动生成文件 项目结构: xx 实现思路: 1.添加依赖 <?xml version="1.0" e ...

  5. mybatis自动生成java代码

    SSM框架没有DB+Record模式,写起来特别费劲,只能用下面的方法勉强凑合. 上图中,*.jar为下载的,src为新建的空白目录,.xml配置如下. <?xml version=" ...

  6. Mybatis自动生成实体类

    Maven自动生成实体类需要的jar包 一.pom.xml中 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns ...

  7. 使用mybatis-generator插件结合tk.mybatis自动生成mapper二三事

    本篇文章将介绍使用spring boot框架,引入mybatis-generator插件,结合tk.mybatis自动生成Mapper和Entity的一整套流程,其中包括最重要的踩坑与填坑.     ...

  8. mybatis自动生成代码插件mybatis-generator使用流程(亲测可用)

    mybatis-generator是一款在使用mybatis框架时,自动生成model,dao和mapper的工具,很大程度上减少了业务开发人员的手动编码时间 坐着在idea上用maven构建spri ...

  9. 使用mybatis-generator插件结合tk.mybatis自动生成mapper

    本篇文章将介绍使用spring boot框架,引入mybatis-generator插件,结合tk.mybatis自动生成Mapper和Entity的一整套流程,其中包括最重要的踩坑与填坑.     ...

随机推荐

  1. JavaScript 对象(上)

    简述: 1.是 JavaScript 的基本类型 2.是一种复合值,可通过名字访问这些值 3.可看作属性的无序集合,每个属性都是一个名/值对(属性名是字符串或标识符) 4.可以从一个称为原型的对象继承 ...

  2. JavaScript 作用域、命名空间及闭包

    变量作用域: 1.一个变量的作用域是程序源代码中定义这个变量的区域 2.在函数内声明的变量是局部变量,它只在该函数及其嵌套作用域里可见(js 函数可嵌套定义):不在任何函数内声明或在函数内不使用 va ...

  3. Error running 'Unnamed': Address localhost:1099 is already in use

    当使用idea运行项目时,出现‘Error running 'Unnamed': Address localhost:1099 is already in use’. 解决方案: 1.打开任务管理器 ...

  4. Node.js项目拆包工程化

    背景 在我们开发的过程中,经常会遇到这样的问题,开发完了一些代码或者一个接口,别的小伙伴过来问你,代码可不可以给他复用,接口可以给他调用.这说明代码的复用和抽象对团队协作是很重要的.举个例子,如下图 ...

  5. 给大家一些改善 Python 程序的 91 个建议

    读了一本还不错的书「编写高质量代码改善 Python 程序的 91 个建议」,大多数的建议是真心不错,我虽然写python也有3年多了,但是有些地方确实没去注意过,特地整理了一下,给大家参考. 我已经 ...

  6. 【zookeeper】4、利用zookeeper,借助观察模式,判断服务器的上下线

    首先什么是观察者模式,可以看看我之前的设计模式的文章 https://www.cnblogs.com/cutter-point/p/5249780.html 确定一下,要有观察者,要有被观察者,然后要 ...

  7. 微信支付提示System:access_denied

    原因: 发起授权请求的页面必须是在授权目录下的页面,而不能是存在与子目录中.否则会返回错误,android返回“System:Access_denied”,ios返回"access_cont ...

  8. 扒一扒.net、.net framework、mono和Unity

    zhaichao 标签: .net.net frameworkc#monounity 2017-04-23 14:39 425人阅读 评论(0) 收藏 举报 版权声明:本文为博主原创文章,未经博主允许 ...

  9. Java核心技术及面试指南 键值对方面的面试题总结以及答案

    3.3.5.1如何遍历HashMap对象?尤其请说明通过Iterator遍历HashMap对象的方法. 建议用这种方式: Set<Entry<String,String>>en ...

  10. iOS逆向开发(2):获取APP的类声明 | class-dump | dumpdecrypted

    之前介绍了怎么操作越狱的iOS设备(以下简称为手机),但简单操作手机并不是目标,小程的目标是手机上特定的APP,比如微信.淘宝.QQ音乐等等,因为小程可以从这些APP上拿到一些有用的信息或资源--比如 ...