简体   繁体   中英

How to read system properties from .properties file

I have a JAVA web application which runs on Tomcat Server. I have a setup a property in my tomcat's VM arguments; something like -Denvironment =“E1”.

I want to read that property inside my app.properties file, I tried mutiple options like ${environment} and {sys:environment} but could not able to read the value.

Please help, thanks in advance.

你也可以试试这个:

${sys:environment}

It all depends on the class you are using to load your properties, because Java dont support this.

If you try with

${sys:environment}

You should use Commons-Configuration

http://commons.apache.org/proper/commons-configuration/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM