File tree Expand file tree Collapse file tree
2-EventDriven/java-consumer/src/main/java/no/soprasteria Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66import org .springframework .boot .autoconfigure .SpringBootApplication ;
77import org .springframework .scheduling .annotation .EnableScheduling ;
88
9+ import java .util .Arrays ;
10+
911@ SpringBootApplication
1012@ EnableScheduling
1113public class Application {
@@ -14,6 +16,16 @@ public class Application {
1416
1517 public static void main (String [] args ) {
1618 log .info ("Starting RabbitMQ Application" );
17- SpringApplication .run (Application .class , args );
19+ SpringApplication app = new SpringApplication (Application .class );
20+ if (harIkkeSattEnvVariablerForProd (args )) {
21+ app .setAdditionalProfiles ("local" );
22+ }
23+ app .run (args );
24+ }
25+
26+ private static boolean harIkkeSattEnvVariablerForProd (String [] args ) {
27+ boolean sattEnv = System .getenv ().keySet ().stream ().anyMatch (k -> k .toLowerCase ().startsWith ("spring_profiles_active" ));
28+ boolean argsSatt = Arrays .stream (args ).anyMatch (arg -> arg .toLowerCase ().startsWith ("spring.profiles.active" ));
29+ return !(sattEnv || argsSatt );
1830 }
1931}
You can’t perform that action at this time.
0 commit comments