gradle + springboot 搭建多环境

最近听说springboot2.0开始使用gradle来管理项目了,好像是因为mavn打包太慢的原因。

今天我来试试gradle如何在springboot2.0搭建多环境;

其实找了好多文章,很多都是项目比较大的,配置整套环境,比如可以配置sourceSets 可以配置很多,里面就不多说,网上很多。

因为习惯了mavn,不说废话,直接上配置

配置文件:

bulid.gradle中这样配置: 

// prod
tasks.register("bootRunProd") {
    group = "application"
    description = "Runs the Spring Boot application with the prod profile"
    doFirst {
        tasks.bootRun.configure {
            systemProperty("spring.profiles.active", "prod")
        }
    }
    finalizedBy("bootRun")
}
// dev
tasks.register("bootRunDev") {
    group = "application"
    description = "Runs the Spring Boot application with the dev profile"
    doFirst {
        tasks.bootRun.configure {
            systemProperty("spring.profiles.active", "dev")
        }
    }
    finalizedBy("bootRun")
}

group 组

desription 描述

doFirst 首先开始做的集合

finalizedBY 结束后do

 

运行一下dev环境: 成功

 

总结:

我注册一个task, 然后group是application。首先就是设置systemProperty, 就是就是配置vm的参数 类似-Dspring.profiles.active=x; 结束后在运行bootRun。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值