Search code examples
javaspringapplicationcontext

Property-placeholder using envriomental variables as CATALINA_HOME


I would like to use a Envriomental variable in the location of property-placeholder but I don't get it:

I tried in this way:

<context:property-placeholder location="${CATALINA_HOME}/conf/database.properties" order="0"/>

but I get this error

org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/${CATALINA_HOME}/conf/database.properties]

Also, I don't find documentation about use envriomental variables in the context configuration or property-placeholder.

Kind regards.


Solution

  • I think you should do it like this:

    <context:property-placeholder location="#{ systemProperties['CATALINA_HOME'] }/conf/database.properties"/>
    

    If I didn't understand you wrong.