gradle自动生成java,Springboot+gradle+Mybatis-Generator 代码自动生成器

今天看了mybatis-Generator的官方文档,研究了一下,决定自己也搭一个,但是官方文档和大部分资料都是基于maven项目的,查了gradle的官方文档,终于找到了官方配置,很激动(^-^)V,记录下来,方便记忆也同时分享给大家~

mybatis-Generator官方文档:http://www.mybatis.org/genera...

Gradle官方文档:https://plugins.gradle.org/pl...

gradle

buildscript {

ext {

springBootVersion = '1.5.10.RELEASE'

}

repositories {

mavenCentral()

//添加maven仓库

maven {

url "https://plugins.gradle.org/m2/"

}

}

dependencies {

classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")

// mybatis-generator 插件路径

classpath "gradle.plugin.com.arenagod.gradle:mybatis-generator-plugin:1.4"

}

}

apply plugin: 'java'

apply plugin: 'eclipse'

apply plugin: 'org.springframework.boot'

//引入 mybatis-generator 插件

apply plugin: "com.arenagod.gradle.MybatisGenerator"

group = 'com.example'

version = '0.0.1-SNAPSHOT'

sourceCompatibility = 1.8

repositories {

mavenCentral()

}

dependencies {

compile('org.springframework.boot:spring-boot-starter-web')

testCompile('org.springframework.boot:spring-boot-starter-test')

//数据源

compile 'com.alibaba:druid-spring-boot-starter:1.1.2'

compile 'mysql:mysql-connector-java:6.0.6'

//配置mybatis

compile "org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1"

//mybatis-generator core 包

compile group: 'org.mybatis.generator', name: 'mybatis-generator-core', version:'1.3.2'

}

configurations {

mybatisGenerator

}

// mybatis-generator.xml 配置路径

//这里会遇到个问题:MyBatis Generator 通过xml生成,有日志但是没有生成文件成功的问题,

//原因:mac下是找不到 ./src 路径的,需要全路径,如下配置。windows则为src/main/resources/generator.xml

mybatisGenerator {

verbose = true

configFile = '/Users/murasakiseifu/mybatisGenerator/src/main/resources/generator.xml'

}

generator.xml

按照刚才的配置路径,在 resources 文件夹下建立 generator.xml

/p>

PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"

"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

connectionURL="jdbc:mysql://127.0.0.1:3306/takin_write"

userId="murasakiseifu"

password="123456">

domainObjectName="Student" enableCountByExample="false"

enableDeleteByExample="false" enableSelectByExample="false"

enableUpdateByExample="false">

生成代码

双击 mbGenerator

bV4WYq?w=1476&h=1124

出现如下提示为成功

bV4WYK?w=3358&h=734

包结构

bV4WYT?w=1004&h=1294

参考

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值