Setting active profiles when launching Spring Boot application via gradle

I wanted to use a profile specific application.properties file for my Spring Boot application. But Gradle was not picking it up when I ran my launched with the following command:

gradle bootRun -Dspring.profiles.active=dev

The solution turned out be be simply adding the snippet below to my build.gradle file. This snippet is telling Gradle to pull in the system properties.

bootRun {
    systemProperties = System.properties
}

One thought on “Setting active profiles when launching Spring Boot application via gradle

Leave a Reply

Your email address will not be published. Required fields are marked *