我在stackoverflow.com上看到过类似的问题,但是没有任何解决方案对我有帮助。以下是我使用的配置(maven项目结构):位于
在Spring配置中:
基于
当我使用
src/main/resources/properties/app.properties
文件中。#possible values: dev test prod
mode: dev
在Spring配置中:
<context:property-placeholder location="classpath:properties/app.properties"/>
<import resource="classpath:/spring/db/${mode}-datasource-config.xml"/>
基于
${mode}
的值,我希望能导入相应的数据源配置文件。当我使用
mvn clean install tomcat7:run
命令运行嵌入式Tomcat7时,我遇到了错误:10, 2013 5:52:29 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /SpringWebFlow threw load() exception
java.lang.IllegalArgumentException: Could not resolve placeholder 'mode' in string value "classpath:/spring/db/${mode}-datasource-config.xml"
存在target/classes/properties/app.properties
文件。
我正在使用IntelliJ IDEA,在编辑器中,我可以单击<import resource="classpath:/spring/db/${mode}-datasource-config.xml"/>
中的"${mode}"并查看其在属性文件中的值。此外,编辑器本身将${mode}
更改为灰色的dev
,显示它可以识别属性值。在编辑器中,我看到:<import resource="classpath:/spring/db/dev-datasource-config.xml"/>
有什么想法为什么我会出现错误以及如何解决?