title: Setting SPRING_PROFILES_ACTIVE inside of Spring Boot custom embedded launch.script
body: <p>We have executable spring boot jars.  Some environment variables are provided via the runtime account's .bashrc , including SPRING_PROFILES_ACTIVE . This is set at runtime through checking some system parameters.</p>
  
  <p>In order to enable a truly portable application, we would like to set these variables inside a custom version of the Spring Boot executable launch script (launch.script) instead of relying upon a custom .bashrc being deployed somewhere. </p>
  
  <p>i.e. the launch script runs the custom shell code that is currently in our bashrc .</p>
  
  <p>We could then throw the Spring Boot executable jar on one of our boxes without having to deploy the custom .bashrc .</p>
  
  <p>We have copied the default Spring Boot launch.script and prepended setting our environment variables. We replace the default script with our custom one by using the spring-boot-maven-plugin. Using echo statements, we know that the new launch.script replaces the default one.</p>
  
  <p>One environment variable we are setting dynamically is SPRING_PROFILES_ACTIVE . Through an echo statement, I know that the variable is being set correctly inside of our custom launch.script. However, that value is not being propagated to the application. i.e. the spring profile at application startup is always 'default', versus L0, L1 or whatever we're trying to set.</p>
  
  <p>I have exported the variable using export and declare -x .  </p>
  
  <p>Is what we are doing at all feasible, or is setting SPRING_PROFILES_ACTIVE in the launch.script too late ?</p>