I have a Spring Boot application running on a JBoss EAP Server. Is there a way to load up a Spring profile based on environment variable set in the Linux Operating System?
Asked
Active
Viewed 866 times
0
-
Possible duplicate of [Read environment variable in SpringBoot](https://stackoverflow.com/questions/44803211/read-environment-variable-in-springboot) – pvpkiran Oct 24 '19 at 12:49
-
@pvpkiran It doesn't say how I can load a Spring profile based on an environment variable. – Ciri Oct 24 '19 at 13:12
-
Just set the `SPRING_PROFILES_ACTIVE` environment variable or pass it as an argument when starting the program using `--spring.profiles.active` – M. Deinum Oct 24 '19 at 13:17
-
@M.Deinum I can only develop my application and provide a war file to the team that deploys it. I can't set any environment variables or provide extra parameters when starting the JBoss server. I can only use what's already available. – Ciri Oct 24 '19 at 13:29
-
If you have a war you should have extended the `SpringBootServletInitializer` and override/implement the `configure` method. In this method check the environment variable, when set, add that as active profile in the `configure` method. – M. Deinum Oct 24 '19 at 13:31