简体   繁体   English

ElasticBeanstalk Java,春季活动配置文件

[英]ElasticBeanstalk Java, spring active profile

I am trying to start a spring boot .jar via AWS ElasticBeanstalk. 我正在尝试通过AWS ElasticBeanstalk启动spring boot .jar。 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). 是否有人知道如何为Java ElasticBeanstalk应用程序(而非tomcat)设置活动配置文件(spring.profiles.active)。 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. 我已经在AWS管理控制台中设置了“ spring.profiles.active”环境属性,但是它不起作用。

Thanks and Best Regards Alex 谢谢和最好的问候亚历克斯

The casing is different when set as an Environment Variable versus the command line property. 当设置为环境变量与命令行属性时,大小写不同。 Try setting SPRING_PROFILES_ACTIVE in your EB Configuration. 尝试在EB配置中设置SPRING_PROFILES_ACTIVE。

AWS EB doesn't pass variables with dots in names to deployed app. AWS EB不会将名称中带有点的变量传递给已部署的应用程序。 You have to replace dots with underscores and use upper case, eg: 您必须用下划线替换点并使用大写字母,例如:

SPRING_PROFILES_ACTIVE=prod

ElasticBeanStack Web UI has a tab named Configuration. ElasticBeanStack Web UI有一个名为“配置”的选项卡。 Inside that,there will be a Box (Card ) named software Configuration. 在其中,将有一个名为Software Configuration的Box(卡)。 There you need to set SPRING_PROFILES_ACTIVE to prod 在那里,您需要将SPRING_PROFILES_ACTIVE设置为prod

在此处输入图片说明

在此处输入图片说明

Similarly With AWS LAMBDA: 与AWS LAMBDA类似:

In $ sam local you add the following line in your sam template yml file: $ sam local下行添加到sam模板yml文件中:

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

But in AWS Console: in your Lambda Environment variables just add: 但是在AWS Console中:在Lambda Environment变量中只需添加:

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

在此处输入图片说明

For anyone else who comes across this answer. 对于遇到此问题的其他人。 The above answer was correct and we were using the SPRING_PROFILES_ACTIVE environment variable successfully. 上面的答案是正确的,我们正在成功使用SPRING_PROFILES_ACTIVE环境变量。 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. 但是,在最近(2019年10月)设置新环境时,我们注意到现在已经更改了,并且应该将环境变量设置为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 因此,答案应该是,根据您的Elastic beantalk设置,您应该在Elastic beanstalk Web UI配置选项卡中设置SPRING_PROFILES_ACTIVE或设置spring.profiles.active

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM