2012-06-19 33 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

相關問題