1.Pom.xml文件配置:

代码:

<plugins>

<!-- Mybatis generator代码生成插件 配置 -->

<plugin>

<groupId>org.mybatis.generator</groupId>

<artifactId>mybatis-generator-maven-plugin</artifactId>

<version>${plugin.mybatis.generator}</version>

<configuration>

<configurationFile>${mybatis.generator.generatorConfig.xml}</configurationFile>

<overwrite>true</overwrite>

<verbose>true</verbose>

</configuration>

</plugin>

2.在resource目录下创建generatorConfig.properties和generatorConfig.xml两个文件。

2.1 .generatorConfig.properties文件配置

# 数据库驱动jar 路径

drive.class.path=C\:\\Users\\Administrator\\.m2\\repository\\mysql\\mysql-connector-java\\5.1.30\\mysql-connector-java-5.1.30.jar

# 数据库连接参数

jdbc.driver=com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://localhost:3306/ssm?useUnicode=true&characterEncoding=utf-8

jdbc.username=simple

jdbc.password=1234

# 包路径配置

根据项目的包路径设置成自己的路径

model.package=com.ln.web.model

dao.package=com.ln.web.dao

xml.mapper.package=com.ln.web.mapper

target.project=src/main/java

2.2.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">

<!-- 配置Run As Maven build : Goals 参数 : mybatis-generator:generate -Dmybatis.generator.overwrite=true -->

<!-- 配置 tableName,使用 Run As Maven build 生成 dao model 层 -->

<generatorConfiguration>

<!-- 配置文件路径 -->

<properties url="${mybatis.generator.generatorConfig.properties}"/>

<!--数据库驱动包路径 -->

<classPathEntry location="${drive.class.path}"/>

<context id="DB2Tables" targetRuntime="MyBatis3">

<!--关闭注释 -->

<commentGenerator>

<property name="suppressAllComments" value="true"/>

</commentGenerator>

<!--数据库连接信息 -->

<jdbcConnection driverClass="${jdbc.driver}" connectionURL="${jdbc.url}" userId="${jdbc.username}"

password="${jdbc.password}">

</jdbcConnection>

<!--生成的model 包路径 -->

<javaModelGenerator targetPackage="${model.package}" targetProject="${target.project}">

<property name="enableSubPackages" value="ture"/>

<property name="trimStrings" value="true"/>

</javaModelGenerator>

<!--生成xml mapper文件 路径 -->

<sqlMapGenerator targetPackage="${xml.mapper.package}" targetProject="${target.project}">

<property name="enableSubPackages" value="ture"/>

</sqlMapGenerator>

<!-- 生成的Dao接口 的包路径 -->

<javaClientGenerator type="XMLMAPPER" targetPackage="${dao.package}" targetProject="${target.project}">

<property name="enableSubPackages" value="ture"/>

</javaClientGenerator>

<!--对应数据库表名 -->

<table tableName="user_table"></table>

</context>

</generatorConfiguration>

3.运行

项目右键-->run as-->maven build

Mybatis+maven自动构建dao、mapper、model的更多相关文章

  1. Mybatis-Generator 自动生成Dao、Model、Mapping相关文档

    最近在学习mybatis,结果在写Mapping的映射文件时insert语句一直报错,于是想看看标准的映射文件是什么样.百度到Mybatis-Generator 自动生成Dao.Model.Mappi ...

  2. 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)-----https://www.cnblogs.com/smileberry/p/4145872.html

    https://www.cnblogs.com/smileberry/p/4145872.html 使用Mybatis-Generator自动生成Dao.Model.Mapping相关文件(转)

  3. mybatis generator 自动生成dao层映射代码

    资源: doc url :http://www.mybatis.org/generator/ download:https://github.com/mybatis/generator/release ...

  4. Mybatis-Generator插件自动生成Dao、Model、Mapping相关文件

    最近做项目,mapping 有点多而且容易写错,于是试着用了Mybatis-Generator 插件自动生成 dao, domain  mapping 文件.感觉还挺好用.把相关配置分享,一边以后做项 ...

  5. 使用Mybatis-Generator自动生成Dao、Model、Mapping

    Mybatis属于半自动ORM,在使用这个框架中,工作量最大的就是书写Mapping的映射文件,由于手动书写很容易出错,我们可以利用Mybatis-Generator来帮我们自动生成文件. 1.相关文 ...

  6. Mybatis-Generator自动生成Dao、Model、Mapping等相关映射文件(懒人版)

    今天在学习mybatis生成相关的映射文件的时候,发现了往期的生成Dao.Model.Mapping等文章多数都是一样的,我也在学着重复造轮子,不过是懒人造的.本文旨在解决开发过程,简化配置文件的“手 ...

  7. mybatis+maven自动生成代码框架

    说明 通过可配置化,通过数据库自动生成model,da和mapper文件,这对于可定制化开发来说是非常有用的,减少了很多重复的工作. 添加依赖 <properties> <proje ...

  8. 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)

    Mybatis属于半自动ORM,在使用这个框架中,工作量最大的就是书写Mapping的映射文件,由于手动书写很容易出错,我们可以利用Mybatis-Generator来帮我们自动生成文件. 1.相关文 ...

  9. 10.使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)

    出处:http://www.cnblogs.com/lichenwei/p/4145696.html Mybatis属于半自动ORM,在使用这个框架中,工作量最大的就是书写Mapping的映射文件,由 ...

随机推荐

  1. bzoj 5210 最大连通子块和——动态DP

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=5210 似乎像bzoj4712一样,依然可以用别的方法做.但还是只写了动态DP. 当然是dp[ ...

  2. bae3.0第一步 添加框架支持

    1.克隆bae上应用代码: 先在本地linux机器上创建文件夹bae并进入, 再执行git clone https://git.duapp.com/appidd01iud80bg 结果会在bae文件夹 ...

  3. 一般处理程序+html 的CRUD

    using Console_Core.BLL; using Console_Core.Common; using Console_Core.Model; using System; using Sys ...

  4. phyton方面相关书籍

    0基础:<简明PYTHON教程>http://linux.chinaitlab.com/manual/Python_chinese/<与孩子一起学编程>http://book. ...

  5. Unreal Engine 4 Radiant UI 入门教程(一)制作Radiant HUD

    请注意:本篇教程的编号是从零开始的,如果没有看第零篇教程,请前往学习. 本教程介绍如何制作Radiant HUD,这是指将网页元素直接加入到HUD中,效果为: 对应的网页元素为: 第一步: 将之前下载 ...

  6. Oracle 静默安装的db_install.rsp 文件

    Oracle 静默安装的db_install.rsp 文件,已修改好值 ################################################################ ...

  7. 实验吧CTF题库-编程(部分)

    百米 3秒提交答案,数字是随机变化的 利用Python脚本解题 # -*- coding:utf-8 -*- __author__ = "MuT6 Sch01aR" import ...

  8. 2016.1.23 通过cmd在程序中执行sql脚本

    System.Diagnostics.Process pro = new System.Diagnostics.Process(); pro.StartInfo.FileName = "cm ...

  9. vue中父子组件传递信息实现

    为了能够在父子组件中实现双向控制,需要以下的步骤: 第一步:子组件中挖坑 (1)在需要父组件填充具体内容的地方挖坑,方式为 <slot name="message">& ...

  10. Compare and Swap(CAS)

    CAS(Compare and Swap)是个原子操作.拿到一个新值后,CAS将其与内存中的值进行比较,若内存中的值和这个值不一样,则将这个值写入内存,否则,不做操作.在Java的 java.util ...