问题
When running jetty project under IntelliJ I have no problem to read environment variable I set to /etc/environment using the System.getenv("var1") api.
When I deploy the war to Ubuntu server that start Jetty at boot, I get null when calling System.getenv("var1")
When I run a simple console application on the server under my user (suder user) I get the environment variable currently.
What I need to do in order to make the environment variables in /etc/environment visible to the war when it start automatically not under a user session?
回答1:
I think I needed to adjust this in the jetty.sh when I was getting things working on elastic beanstalk...
In the jetty.sh script you can source the /etc/environment file and they will be present. If that is what you are looking for then open a bug for it and we'll add it into the jetty.sh script for the next release.
来源:https://stackoverflow.com/questions/15884105/jetty-and-etc-environment-on-ubuntu-12-10