ElasticBeanstalk Java, spring active profile

2020-08-09 09:51发布

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

4条回答
手持菜刀,她持情操
2楼-- · 2020-08-09 09:58

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
查看更多
ら.Afraid
3楼-- · 2020-08-09 09:58

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

查看更多
祖国的老花朵
4楼-- · 2020-08-09 10:03

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

查看更多
▲ chillily
5楼-- · 2020-08-09 10:03

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

查看更多
登录 后发表回答