• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

mybatis_generator_gradle_plugin: mybatis生成器gradle插件

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

mybatis_generator_gradle_plugin

开源软件地址:

https://gitee.com/cuisongliu/mybatis_generator_gradle_plugin

开源软件介绍:

Build StatusDependency Statuslicenselicense

mybatis生成器gradle插件(MBG)

这个插件是基于https://github.com/mybatis/generator maven插件做的.这个gradle插件是mybatis生成插件.这个插件拥有了mybatisGeneratorPlugin(mbg)的全部功能,这个插件实现在gradle3.3上使用groovy实现.English

添加mbg插件到你的项目

使用在所有Gradle版本的构建脚本片段:
buildscript {  repositories {    maven {      url "https://plugins.gradle.org/m2/"    }  }  dependencies {    classpath "gradle.plugin.com.cuisongliu.plugin:mybatis-generator:0.9.6"  }}apply plugin: "com.cuisongliu.plugin.mybatis-generator"

为Gradle 2.1中引入的新的,潜在的插件机制构建脚本代码段

plugins {  id "com.cuisongliu.plugin.mybatis-generator" version "0.9.6"}

参数配置

mbg {  overwrite = false  consoleable = true  jdbc{    driver = "com.mysql.jdbc.Driver"    url    = "jdbc:mysql://[ip]:[port]/[dbname]?useSSL=false"    username = "username"    password = "password"  }  xml{      resourcesProject = "src/main/java"      mapperPlugin = tk.mybatis.mapper.generator.MapperPlugin.class      mapperMapper = "com.cuisongliu.springboot.core.mapper.MyMapper"      mapperPackage= "com.cuisongliu.mapper"      modelPackage = "com.cuisongliu.entity"      xmlPackage =   "com.cuisongliu.mapper"      tableName ="s_system"      objectName ="System"      mapperSuffix ="Mapper"  }}

如果没有设置,插件试图智能使用默认值.

       
属性名        类型       描述       默认值
overwrite boolean 是否覆盖已经生成的xml或者代码 true
generatorFile String mbg的配置文件位置 generatorConfig.xml
sqlScript String 要在生成代码之前运行的 SQL 脚本文件的位置. null
consoleable boolean 如果指定该参数,执行过程会输出到控制台。 false
skip boolean 是否跳过生成代码的mbg的任务 false
contexts String 如果指定了该参数,逗号隔开的这些context会被执行。 null
tableNames String 如果指定了该参数,逗号隔开的这个表会被运行。 null
       
属性名        类型       描述       默认值
jdbc driver String jdbc的驱动类.不能为空 null
url String jdbc的数据库url.不能为空 null
username String jdbc的数据库用户名.不能为空 root
password String jdbc的数据库密码.不能为空 null
xml javaProject String 生成java文件所在的目录. src/main/java
resourcesProject String 生成xml配置文件mapper所在的目录. src/main/resources
mapperPackage String mapper配置,生成的Mapper(dao)所在的包所在的位置.不能为空 null
modelPackage String model配置,生成的实体类所在的包所在的位置.不能为空 null
xmlPackage String mapper的xml配置,生成的mapper的xml所在的包的位置.不能为空 null
mapperPlugin Class extends PluginAdapter> 插件信息,xml中插件的类名.不能为空 tk.mybatis.mapper. generator.MapperPlugin. class
mapperMapper String mapper配置,生成的Mapper方法的父类.不能为空 tk.mybatis.mapper. common.Mapper
tableName String mybatis生成对应的数据库表名.不能为空 null
objectName String mybatis生成对应的实体类名.不能为空 null
mapperSuffix String mybatis生成Mapper的后缀 Mapper

运行mbg任务

  1. 加入generatorConfig.xml到你的执行模块中去,设置table信息中的变量即可,文件中.

  2. 在build.gradle中加入参数配置

  3. 在build.gradle所在目录执行 gradle mbg

  4. 默认支持mysql,若使用oracle或者其他的数据库需要额外增加如下配置

        buildscript{        def baseUrl = "http://maven.cuisongliu.com"        def nexusUrl = "$baseUrl/content/groups/public/"        repositories {            mavenLocal()            maven { url "$nexusUrl" }        }        dependencies {            classpath "com.oracle:ojdbc6:11.1.0.7.0"        }    }

    在使用插件之前加入buildscript,配置classpath的driver依赖jar包(这里的maven地址根据情况修改)


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap