20

I am trying to start a spring boot .jar via AWS ElasticBeanstalk. Everything works fine, with the profile "default". Does anybody know how to set the active profile(spring.profiles.active) for a java ElasticBeanstalk app(not tomcat). I always get "No active profile set, falling back to default profiles: default". Is there a way to directly set vm options?

I already set a "spring.profiles.active" Environment Property in AWS Admin Console, but it doesn't work.

Thanks and Best Regards Alex

Alex Haider
  • 233
  • 2
  • 3
  • 5

4 Answers4

38

The casing is different when set as an Environment Variable versus the command line property. Try setting SPRING_PROFILES_ACTIVE in your EB Configuration.

Thorn G
  • 12,620
  • 2
  • 44
  • 56
  • @TomG where can I find the EB configuration file?? I'm having the same issue. – Yogen Rai May 24 '17 at 19:21
  • @YogenRai OP was setting an Environment Variable (presumably through the ElasticBeanstalk web UI) -- there is no "file" for EB. – Thorn G May 24 '17 at 19:35
  • 6
    For anyone else who comes across this answer. The above answer was correct and we were using the SPRING_PROFILES_ACTIVE environment variable successfully. However, in setting up a new environment recently (October 2019) we noticed that this has now changed and the environment variable should be set to spring.profiles.active. So, the answer should be, depending on your elastic beanstalk setup you should either set SPRING_PROFILES_ACTIVE in the elastic beanstalk web UI configuration tab OR set spring.profiles.active instead – TC888 Oct 03 '19 at 14:18
10

ElasticBeanStack Web UI has a tab named Configuration. Inside that,there will be a Box (Card ) named software Configuration. There you need to set SPRING_PROFILES_ACTIVE to prod

enter image description here

enter image description here

sapy
  • 8,952
  • 7
  • 49
  • 60
5

AWS EB doesn't pass variables with dots in names to deployed app. You have to replace dots with underscores and use upper case, e.g.:

SPRING_PROFILES_ACTIVE=prod
Boris
  • 492
  • 4
  • 9
3

Similarly With AWS LAMBDA:

In $ sam local you add the following line in your sam template yml file:

Resources:
   FunctionName:
       Properties:
           Environment:
               Variables:
                  SPRING_PROFILES_ACTIVE: local

But in AWS Console: in your Lambda Environment variables just add:

KEY:JAVA_TOOL_OPTIONS VALUE:-Dspring.profiles.active=dev

enter image description here

Jay Ehsaniara
  • 1,421
  • 17
  • 24