[英]How to use RDS environment properties attached to Elastic Beanstalk Environment - Java
I created an ElasticBeanstalk env with an RDS attached to it.我创建了一个 ElasticBeanstalk 环境,并附加了一个 RDS。 The platform of the instance using Corretto 8 running on 64bit Amazon Linux 2.
使用 Corretto 8 的实例平台在 64 位 Amazon Linux 2 上运行。
It says here that the RDS settings are available as environment properties like RDS_HOSTNAME
and here it states that in Java, we could retrieve them using System.getenv()
.它在这里说 RDS 设置可用作
RDS_HOSTNAME
等环境属性, 在这里它说明在 Java 中,我们可以使用System.getenv()
检索它们。
But when I try it on the EC2 instance, it returns null
.但是当我在 EC2 实例上尝试时,它返回
null
。 Hence, when I use ${RDS_HOSTNAME}
in my application.properties file, the spring app fails to start.因此,当我在 application.properties 文件中使用
${RDS_HOSTNAME}
时,spring 应用程序无法启动。
I see one tutorial doing quite the same with what I do here but I could not figure out what is wrong with my settings.我看到一个教程与我在这里所做的完全相同,但我无法弄清楚我的设置有什么问题。 Any ideas?
有任何想法吗?
You have to export them first .您必须先导出它们。 You can try the following as
root
:您可以以
root
身份尝试以下操作:
export $(cat /opt/elasticbeanstalk/deployment/env | xargs)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.