How to run bootRun with spring profile via gradle task

前端 未结 13 1373
误落风尘
误落风尘 2020-12-04 19:20

I\'m trying to set up gradle to launch the bootRun process with various spring profiles enabled.

My current bootRun configuration looks lik

相关标签:
13条回答
  • 2020-12-04 20:11

    For those folks using Spring Boot 2.0+, you can use the following to setup a task that will run the app with a given set of profiles.

    task bootRunDev(type: org.springframework.boot.gradle.tasks.run.BootRun, dependsOn: 'build') {
        group = 'Application'
    
        doFirst() {
            main = bootJar.mainClassName
            classpath = sourceSets.main.runtimeClasspath
            systemProperty 'spring.profiles.active', 'dev'
        }
    }
    

    Then you can simply run ./gradlew bootRunDev or similar from your IDE.

    0 讨论(0)
提交回复
热议问题