by BehindJava

How to configure active profile in Spring Boot via Maven

Home » springboot » How to configure active profile in Spring Boot via Maven

In this tutorial we are going to learn about configuring active profile in Spring Boot with the build environment as Maven.

The Maven profile and the Spring profile are two completely different things. Your pom.xml defines variable which is available in the build process, but not at runtime. That is why only the default profile is activated.

How to bind Maven profile with Spring?

You need to pass the build variable to your application so that it is available when it is started.

Define a placeholder in your

The variable must match the declared property from the Maven profile.

Enable resource filtering in you pom.xml:


When the build is executed, all files in the src/main/resources directory will be processed by Maven and the placeholder in your will be replaced with the variable you defined in your Maven profile.

There are other ways to set profiles for your springboot application.

You can add this in your property file:

Programmatic way:


Tests make it very easy to specify what profiles are active


In a Unix environment

export spring_profiles_active=dev

JVM System Parameter

Example: Running a springboot jar file with profile.

java -jar application.jar