我很难加载一个参数,该参数在带有spring context 3.2.4.RELEASE的属性文件中定义。我的web-application-context.xml
看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<context:property-placeholder system-properties-mode="ENVIRONMENT" ignore-resource-not-found="false" ignore-unresolvable="false" location="file:${runtime.dir}/config/properties.txt" />
<import resource="test-${myBooleanParameter}.xml" />
我的properties.txt
看起来像这样:
myBooleanParameter=true
在我的web.xml
中有以下代码段:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:web-application-context.xml</param-value>
</context-param>
不幸的是我收到了这个错误:
Unexpected exception parsing XML document from class path resource [web-application-context.xml]; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'myBooleanParameter' in string value "test-${myBooleanParameter}.xml"
我查看了他正在使用的来源,我认为正确的propertySource甚至没有注册PropertySource
。这是propertySources
中的PropertyPlaceholderHelper.parseStringValue
列表:
http://i.stack.imgur.com/jkQM2.png
可以在此处找到完整的调试日志:http://tny.cz/0ec9c339