Issue
We have a springboot/Tomcat server running on Elastic Beanstalk. We want to use the Env vars set in beanstalk in our springboot code. Currently we have something like
Private string getvar = System.getenv("ENV_VAR");
//and have also tried
Private string getvar = System.getProperty("ENV_VAR");
Locally this works just fine. When it's on aws, it can't find the variables. We have them set in our EB Instance -> Configuration -> Software -> Environment Variables:
Key = ENV_VAR
Value = valueWeExpect
and I confirmed they are set via cloudShell.
Does anyone know if we are missing a dependency or referencing the variables incorrectly? Is there anything we have to add?
Solution
I get my via
@Autowired
private Environment _env;
_env.getProperty("ENV_VAR")
Environment is org.springframework.core.env.Environment
Answered By - denov Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.