3

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。ここで何が欠けていますか?

4

2 に答える 2

0

私はあなたがすべてのxmlディレクティブを持っていると仮定します...あなたのプロパティファイル(あなたのXMLも)のエンコーディングをチェックしてください

于 2012-06-19T22:25:30.730 に答える
0

各インポートの中にプレースホルダーBeanを配置する必要があります。私はあなたが説明しているものと同様の設定をしているので、それが私がそれを機能させることができる唯一の方法です。また、コンテナ内でのIDの競合を防ぐために、BeanからIDを削除しました。

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="WEB-INF/myconfig.properties" />
</bean> 
于 2013-09-10T00:13:01.663 に答える