Skip to content

spring boot not loading default profile while using spring.profile.default in

FYI : I swear there is no activating profile configuration such as -D or run configuration


When application is booted up without any activating profile, the dev profile is activated as a default.


I’ve set spring.profile.default = dev , and I would expect that the dev profile is activated. But it is not.

What I did

Run Environment

Spring-Boot-version : 2.1.2 Release

What I'm referred

1) How to use profiles in Spring Boot Application –

Here’s Code What I did


spring.profiles.default= dev

application.environment=This is a "Default" Environment


application.environment=This is a "dev" Environment
server.port= 8082


public class ProfileController {

    private String applicationEnv;

    public String getApplicationEnv(){
        return applicationEnv;


localhost/v1 => This is a “Default” Environment


I’ve found out the default profile is set up as dev correctly.

This is my spring-boot log.

2019-10-16 23:17:02.926 INFO 64099 — [ main] c.e.s.SpringbootdemoappApplication : No active profile set, falling back to default profiles: dev

Add another log for server port

2019-10-17 00:25:03.837 INFO 68318 — [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8083 (http)

The reason that I add is it doesn’t seem a problem related with Injection.

Time to Close this question

The first goal that I want to achieve is change default profile. From spring docs(, default profile can be changed as setting spring.profiles.default in

But it seems kind of bug (Thanks @Antoniossss). Even if I’ve set that in and the console showed No active profile set, falling back to default profiles: dev. However still dev profile wasn’t activated.

The thing that I’ve found out is changing default profile should be done before loading

It means if changing default profile is described in, it’s too late.(IDK why though, I can’t figure out because there are so many layers in Spring …) If défaut profile is set up using -Dspring.default.profile = dev , it’s working properly.


You can’t change the default profile by declaring it in a config file. It has to be in place before the config files are read.


The problem is you are passing this properties after application is loaded, you need to provide this property while application is booting up

Pass it as JVM args

java -jar -Dspring.profiles.default=dev myproject.jar

Pass as environment variable

java -jar myproject.jar --spring.profiles.default=dev

System variable