Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the default active profile in Spring-boot

I want my default active profile to be production if -Dspring.profiles.active is not set.

I tried the following in my application.properties but it did't work:

spring.profiles.default=production 

Spring-boot version = 1.3.5.RELEASE

like image 820
DarVar Avatar asked Jun 08 '16 10:06

DarVar


People also ask

What is the default active profile in spring boot?

The default profile is always active. Spring Boot loads all properties in application. yml into the default profile. We could rename the configuration file to application-default.

How do I set a spring boot profile?

The solution would be to create more property files and add the "profile" name as the suffix and configure Spring Boot to pick the appropriate properties based on the profile. Then, we need to create three application. properties : application-dev.


2 Answers

What you are doing here is setting the default default profile (the profile that is used on any bean if you don't specify the @Profile annotation) to be production.

What you actually need to do is set the default active profile, which is done like this:

spring.profiles.active=production 
like image 144
PaulNUK Avatar answered Oct 18 '22 06:10

PaulNUK


add --spring.profiles.active=production

Example:

java -jar file.jar --spring.profiles.active=production 
like image 45
Jaya Naresh Avatar answered Oct 18 '22 06:10

Jaya Naresh