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. Spring 实现事务的三种方式

    事务:保证数据的运行不会说A给B钱,A钱给了B却没收到. 实现事务的三种方式(重要代码): 1.aspectJ AOP实现事务: <bean id="dataSourceTransac ...

  2. Mac OS Sierra如何打开任何来源

    我们知道在Mac升级到最新的Mac OS Sierra系统之后,随之而来的是第三方应用都无法打开,提示的是无法打开或扔进废纸篓.而在之前的版本系统中,我们知道在系统偏好设置-->安全性与隐私-- ...

  3. python高级-包(15)

    一.引入包 1.1 有2个模块功能有些联系 receiveMsg.py和sendMsg.py都在msg文件夹里面. 1.2.使用import 文件.模块的方式导入 在桌面创建demo.py文件,并把r ...

  4. AspNetCore微服务下的网关-Kong(一)

    Kong是Mashape开源的高性能高可用API网关和API服务管理层.它基于OpenResty,进行API管理,并提供了插件实现API的AOP.Kong在Mashape 管理了超过15,000 个A ...

  5. Eclipse For JavaEE安装、配置、测试

    Eclipse For JavaEE安装.配置.测试(win7_64bit) 目录 1.概述 2.本文用到的工具 3.安装与配置 4.JavaSE开发测试(确保JDK已正确安装) 5.JavaEE开发 ...

  6. 01 Windows安装Tensorflow

    1.安装Python. 点击此处下载Python3.5.2.安装Python时一定要选择安装pip. 2.配置Python环境变量. 将%安装路径%\Scripts添加到Path下面. 3.修改Pip ...

  7. SQL语句方法语法总结(一)

    1.distinct:返回不重复.唯一的值. select distinct col_name from tbl_name --表中的col_name 列的值 如果有10条一样的,仅返回一条. 2.w ...

  8. SVN不能解锁,报错:没有匹配的可用锁令牌的解决方法

    命令行进入到要解锁的目录,执行 svn unlock 要解锁的文档名 进行解锁:若还是打不开锁,就用强制解锁 , svn unlock -f(--force) 要解锁的文档名 也可以通过 svnadm ...

  9. https://finance.sina.com.cn/realstock/company/sh600522/nc.shtml

    https://finance.sina.com.cn/realstock/company/sh600522/nc.shtml http://hq.sinajs.cn/list=sh601006

  10. [总结] wqs二分学习笔记

    论文 提出问题 在某些题目中,强制规定只能选 \(k\) 个物品,选多少个和怎么选都会影响收益,问最优答案. 算法思想 对于上述描述的题目,大部分都可以通过枚举选择物品的个数做到 \(O(nk^2)\ ...