How to run bootRun with spring profile via gradle task

Spring Boot v2 Gradle plugin docs provide an answer:

6.1. Passing arguments to your application

Like all JavaExec tasks, arguments can be passed into bootRun from the command line using --args="<arguments>" when using Gradle 4.9 or later.

To run server with active profile set to dev:

$ ./gradlew bootRun --args="--spring.profiles.active=dev"

Leave a Comment