我在我的 Web 应用程序的 Spring 上下文中配置了 PropertyPlaceholderConfigurer,该上下文又导入了 JAR 中期望配置某些属性的其他一些上下文。但是由于某种原因,他们无法使用 PropertyPlaceholderConfigurer 值,并且在启动时出现错误:
java.net.URISyntaxException:索引 1 处路径中的非法字符:${dax.svc1.endpoint}
这是我的应用程序上下文的样子:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" name="mhpVariables">
<property name="locations">
<list>
<value>classpath:appconfig.properties</value>
</list>
</property>
</bean>
<import resource="classpath:com.test.svc1/childContext.xml"/>
<import resource="classpath:com.test.svc2/child2Context.xml"/>
</beans>
子上下文是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- connection info -->
<bean class="com.test.java.framework.dataaccess.ServiceConnectionInfo" id="ConnectionInfo">
<property name="defaultUri" value="${dax.svc1.endpoint}"/>
<property name="maxTotalConnections" value="500"/>
<property name="maxConnectionsPerHost" value="50"/>
<property name="readTimeout" value="3000"/>
<property name="ConnectionTimeout" value="1000"/>
</bean>
</beans>
我验证了属性文件在类路径上并且具有属性dax.svc1.endpoint
. 我在这里想念什么?