简体   繁体   English

使用 Jasypt 在 AWS Elastic Beanstalk 上为 Spring Boot 应用程序传递环境变量

[英]Pass environment variable on AWS Elastic Beanstalk for Spring Boot App using Jasypt

I was deploying my Spring Boot Application on AWS Elastic Beanstalk.我正在 AWS Elastic Beanstalk 上部署我的 Spring Boot 应用程序。 My web app is using Jasypt, so in the application.properties file, I wrote down jasypt.encryptor.password= , currently the password in this file is empty, I want to pass the password as a variable on AWS Beanstalk's configuration.我的 Web 应用程序使用 Jasypt,因此在 application.properties 文件中,我写下了jasypt.encryptor.password= ,目前此文件中的密码为空,我想将密码作为变量传递给 AWS Beanstalk 的配置。

When testing locally, I used java -jar myapp.jar --jasypt.encryptor.password=1234 in command line, and it ran successfully.在本地测试时,我在命令行中使用了java -jar myapp.jar --jasypt.encryptor.password=1234 ,运行成功。 However, when deploying on AWS, I added jasypt.encryptor.password in environment properties and set its value to 1234, the app failed to run.但是,在 AWS 上部署时,我在环境属性中添加了jasypt.encryptor.password并将其值设置为 1234,应用程序无法运行。 The log said I cannot set the password as empty.日志说我不能将密码设置为空。 So, at this point Beanstalk did not read the environment property I just set.所以,此时 Beanstalk 并没有读取我刚刚设置的环境属性。 But it can really read the properties later because I tested it after setting another property and used GET API to print it.但它确实可以稍后读取属性,因为我在设置另一个属性并使用 GET API 打印它后对其进行了测试。

My question is: how to make Elastic Beanstalk run/read the environment properties at the beginning?我的问题是:如何让 Elastic Beanstalk 在开始时运行/读取环境属性? In other words, how to make EB run java -jar myapp.jar with --jasypt.encryptor.password=1234 attached?换句话说,如何让 EB 运行带有--jasypt.encryptor.password=1234 java -jar myapp.jar

Thank you so much in advance!非常感谢您!

Procfile can't use environment variables. Procfile不能使用环境变量。 Use a shell script to start the application instead of invoking java -jar directly in Procfile .使用 shell 脚本启动应用程序,而不是直接在Procfile中调用java -jar

Procfile:简介:

web: /bin/sh start_server.sh

start_server.sh启动服务器.sh

#!/bin/bash
JAVA_OPTS='-Djasypt.encryptor.password=1234'
exec java $JAVA_OPTS -jar myapp.jar

references: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html参考资料: https : //docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

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

相关问题 在AWS Elastic Beanstalk上部署Spring Boot应用程序 - 获得502错误 - Deploying Spring Boot app on AWS Elastic Beanstalk — getting 502 error AWS Elastic Beanstalk 环境变量编码和字符集 - AWS Elastic Beanstalk environment variable encoding and charset Spring Boot 应用程序无法在 Elastic Beanstalk 上启动 - Spring Boot App Fails to Start on Elastic Beanstalk AWS Elastic Beanstalk上的Spring Boot / Tomcat仅显示404页面 - Spring Boot / Tomcat on AWS Elastic Beanstalk only showing 404 page 如何将Spring Boot应用程序大战部署到AWS Elastic Beanstalk? - How to deploy Spring Boot application war to AWS Elastic Beanstalk? AWS Elastic Beanstalk-Tomcat Java Spring Boot应用程序出现问题 - AWS Elastic Beanstalk - Problem with tomcat java spring boot application 使用自动 SSL 证书在 AWS Elastic Beanstalk 上部署 Spring Boot 应用程序 - Deploy Spring Boot application on AWS Elastic Beanstalk with automatic SSL certificates AWS-带$的Elastic Beanstalk环境属性 - AWS - Elastic Beanstalk Environment properties with a $ aws 弹性 beantalk 上的 HTTP 到 HTTPS 不适用于 Spring Boot - HTTP to HTTPS on aws elastic beanstalk not working for Spring Boot Spring Boot Application无法在AWS Elastic Beanstalk中进行一次身份验证 - Spring Boot Application not authenticating once in AWS Elastic Beanstalk
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM