[Original] How to read system environment variables in Spring configuration file

Suppose we want to read jboss home, the configuration file is written as follows:
<bean id="wroProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="location" value="file:#{systemProperties['jboss.home.dir']}/standalone/configuration/wro.properties" />  
</bean>

Note the: file:#{systemProperties['jboss.home.dir']} part.
Because jboss will assign the value of the JBOSS_HOME variable to the jboss.home.dir variable when it starts up, in the configuration file, just get the value of jboss.home.dir.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326512043&siteId=291194637