Configuring a Jetty Application with env Variables

I am trying to deploy a WAR WAR file in Jetty 9 with Docker. I would like to set things up like a database URI string, loglevel, and environment variables such that I can also use the docker link functions.

But, if I run the application through java -jar start.jar , the environment variables that I set are not available to the application.

What is the easiest way to pass environment variables to my application?

+3
source share
2 answers

Using system environment variables (aka System.getenv(String) ) is not supported by Jetty start.jar

Feel free to record a feature request with Jetty for this support.

Be aware, however, that the Jetty start.jar process supports properties, either as system properties or as launch properties. Either on the command line or in ${jetty.base}/start.ini

+1
source

I managed to find a solution for Jetty. Just set JAVA_OPTIONS in the Docker file and you should be good to go.

The complete Docker file for my case is as follows:

 FROM jetty:9.2.10 MAINTAINER Me " me@me.com " ENV spring.profiles.active=dev ENV JAVA_OPTIONS="-Dkey=value" ADD myWar.war /var/lib/jetty/webapps/ROOT.war 
0
source

Source: https://habr.com/ru/post/982887/


All Articles