Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 未为导入上下文中的bean解析PropertyPlaceHolderConfigure值_Java_Spring_Properties - Fatal编程技术网

Java 未为导入上下文中的bean解析PropertyPlaceHolderConfigure值

Java 未为导入上下文中的bean解析PropertyPlaceHolderConfigure值,java,spring,properties,Java,Spring,Properties,我在我的web应用程序的Spring上下文中配置了PropertyPlaceHolderConfigure,而Spring上下文又导入了一些JAR中的其他上下文,这些JAR希望配置某些属性。但由于某些原因,PropertyPlaceHolderConfigure值对他们不可用,我在启动时出错: java.net.URISyntaxException:索引1处路径中的非法字符:${dax.svc1.endpoint} 以下是我的应用程序上下文的外观: <?xml version="1.0"

我在我的web应用程序的Spring上下文中配置了PropertyPlaceHolderConfigure,而Spring上下文又导入了一些JAR中的其他上下文,这些JAR希望配置某些属性。但由于某些原因,PropertyPlaceHolderConfigure值对他们不可用,我在启动时出错:

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>

类路径:appconfig.properties
子上下文如下所示:

<?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
。我错过了什么

我假设您拥有所有xml指令。。。检查属性文件的编码(以及XML)

您必须在每个导入中放置一个占位符bean;这是我能让它工作的唯一方法,因为我有一个与你描述的相似的设置。我还从bean中删除了id,以防止容器中出现任何id冲突

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


您所说的xml目标是什么意思?我的xml文件中的编码是utf-8不确定属性文件编码,尽管您使用的是哪个版本的Spring-您能确认一下吗,您在某些地方引用了2.0模式。在Spring 4.3和java config中仍然不起作用。