Liberty server properties file setup

5.4k Views Asked by At

I have properties file in local to which I am reading in code by below method String pathOfFile = System.getProperties("arg.get.prop");

How to set this system properties to get my property file's path in liberty server.xml

3

There are 3 best solutions below

1
On BEST ANSWER

If you need to define system property the recommended way is to use jvm.options file and put your property there like:

# Set a system property.
-Darg.get.prop=ExampleValue

you may need to create that file in the ${server.config.dir} directory. For some more details check Customizing the Liberty environment

0
On

You can specify environment variables in the server.env file placed either in ${wlp.install.dir}/etc/server.env or ${server.config.dir}/server.env. The server will also pick up variables from the current shell environment (server.env files take precedence). Then you can access the variables in the server.xml using the following notation:

${env.<variable name>}

For example, you can have the following in your server.env file:

HTTP_PORT=9001

and then in your server.xml:

<httpEndpoint id="defaultHttpEndpoint"
              httpPort="${env.HTTP_PORT}"
              httpsPort="9443" />

For more information on customizing the Liberty environment see: https://www.ibm.com/support/knowledgecenter/en/SSAW57_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_admin_customvars.html

1
On

if your property file is in "variable=value" format .. then, you can include in in bootstrap.properties file of your liberty install.

bootstrap.properties can be used to supply variable values to liberty configuration. you can include additional files by specifying bootstrap.include=