简体   繁体   English

如何使用附加到 Elastic Beanstalk 环境的 RDS 环境属性 - Java

[英]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.

相关问题 AWS-带$的Elastic Beanstalk环境属性 - AWS - Elastic Beanstalk Environment properties with a $ 如何为运行 Java 应用程序的多 docker 容器 AWS Elastic Beanstalk 环境动态分配内存 - How to dynamically allocate memory to multi-docker container AWS Elastic Beanstalk environment running Java applications 如何从适用于Java的AWS开发工具包克隆Elastic Beanstalk环境? - How can I clone an Elastic Beanstalk environment from the AWS SDK for Java? 如何从aws弹性beanstalk环境中获取堆转储 - How to get heap dump from aws elastic beanstalk environment 如何在AWS Elastic Beanstalk环境中配置负载均衡器? - How do I configure a load balancer in an AWS Elastic Beanstalk environment? Elastic Beanstalk Procfile 中的环境变量不可用 - Environment variables not available in Elastic Beanstalk Procfile 新的 Elastic Beanstalk 环境不打印到日志 - New Elastic Beanstalk Environment not printing to logs AWS Elastic Beanstalk 环境变量编码和字符集 - AWS Elastic Beanstalk environment variable encoding and charset 日志不适用于 Elastic Beanstalk Tomcat 环境 - Logs not working on Elastic Beanstalk Tomcat environment Elastic Beanstalk,Java Spring 引导和 RDS 多可用区部署 - Elastic Beanstalk, Java Spring Boot and RDS Multi AZ Deployment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM