我想在属性占位符的位置使用环境变量,但我不明白:
我尝试过这种方式:
<context:property-placeholder location="${CATALINA_HOME}/conf/database.properties" order="0"/>
但我收到此错误
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]
此外,我没有找到有关在上下文配置或属性占位符中使用环境变量的文档。
亲切的问候。
最佳答案
我认为你应该这样做:
<context:property-placeholder location="#{ systemProperties['CATALINA_HOME'] }/conf/database.properties"/>
如果我没理解错的话。
关于java - 使用环境变量作为 CATALINA_HOME 的属性占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18612217/