Is there a way to activate a spring profile non-programmatically and is it possible to decide which profile is used at runtime?
Asked
Active
Viewed 197 times
1 Answers
2
You can @Autowire
Environment
class which has methods to check active profiles at runtime. Here is environment class documentation.
As for non-programatic profile activation you can start your app like this:
$ java -jar -Dspring.profiles.active=production demo-0.0.1-SNAPSHOT.jar
So spring.profiles.active
is there to set profile.

Nenad Bozic
- 3,724
- 19
- 45
-
is it possible to set the spring.profiles.active property using Ant build file? – ishan3243 Mar 15 '15 at 11:51
-
Maven can so I suppose that ant can as well but haven't used it in ages. In maven you can add `
-Dspring.profiles.active=devel ` to maven execution plugin – Nenad Bozic Mar 15 '15 at 15:23