2012-06-19 23 views
3

我在我的Web应用程序的Spring上下文中配置了PropertyPlaceholderConfigurer,该上下文反过来导入了少量其他上下文,这些上下文位于JAR中,这些上下文需要配置某些属性。但由于某些原因,PropertyPlaceholderConfigurer值洁具不能提供给他们和我得到的启动错误:PropertyPlaceholderConfigurer值在导入的上下文中没有得到解决

java.net.URISyntaxException:Illegalcharacter路径索引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。我在这里错过了什么?

+0

您使用的是哪一个版本的Spring?您能否确认这一点?您在地方提及2.0架构。 –

+0

我正在使用Spring 3 – Debasys

回答

0

你必须把一个占位符豆内的每个进口的;这是我得到它的唯一方法,因为我的设置与您所描述的类似。我还从bean中删除了id以防止容器中的任何id冲突。

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="location" value="WEB-INF/myconfig.properties" /> 
</bean> 
0

我会假设你拥有所有的XML指令,检查你的属性编码文件(也是你的XML)

+0

xml dorectives是什么意思?编码在我的xml文件是utf-8不知道属性文件的编码 – Debasys

相关问题