简体   繁体   English

无法从PropertyPlaceholderConfigurer类Spring中读取属性

[英]Not able to read properties from PropertyPlaceholderConfigurer class spring

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:util="http://www.springframework.org/schema/util" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd 
http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util-3.0.xsd"> 

<!-- ================================================================== --> 
<!-- Locate all property files in specified location to use --> 
<!-- property place holder values ${propertyKey} in context files. --> 
<!-- ================================================================== --> 
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
<property name="locations"> 
<list> 
<!-- default settings --> 
<value>classpath:config/integration.properties</value> 
<value>classpath:config/persistence.properties</value> 
<value>classpath:config/service.properties</value> 
<!-- application-specific settings --> 
<value>classpath:config/application.properties</value> 
<!-- environment-specific settings --> 
<!-- <value>classpath:config/${ie.eircom.ENV}.properties</value> --> 
</list> 
</property> 
<property name="ignoreUnresolvablePlaceholders" value="true"/> 
<property name="ignoreResourceNotFound" value="true"/> 
<property name="systemPropertiesModeName" value="${SYSTEM_PROPERTIES_MODE_OVERRIDE}"/> 

</bean> 

i have this xml through which i have to read SYSTEM_PROPERTIES_MODE_OVERRIDE from PropertyPlaceholderConfigurer class but i am getting this exception. 我有这个xml,我必须通过它从PropertyPlaceholderConfigurer类读取SYSTEM_PROPERTIES_MODE_OVERRIDE,但是我遇到了这个异常。 i have this xml through which i have to read SYSTEM_PROPERTIES_MODE_OVERRIDE from PropertyPlaceholderConfigurer class but i am getting this exception. 我有这个xml,我必须通过它从PropertyPlaceholderConfigurer类读取SYSTEM_PROPERTIES_MODE_OVERRIDE,但是我遇到了这个异常。 i have this xml through which i have to read SYSTEM_PROPERTIES_MODE_OVERRIDE from PropertyPlaceholderConfigurer class but i am getting this exception. 我有这个xml,我必须通过它从PropertyPlaceholderConfigurer类读取SYSTEM_PROPERTIES_MODE_OVERRIDE,但是我遇到了这个异常。

org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 
Caused by: java.lang.IllegalStateException: Failed to load ApplicationContext 
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99) 
at org.springframework.test.context.MergedContextConfiguration.getParentApplicationContext(MergedContextConfiguration.java:281) 
at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:118) 
at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:60) 
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100) 
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:248) 
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64) 
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91) 
... 25 more 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0' defined in class path resource [test-contextNew.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: 
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'systemPropertiesModeName' threw exception; nested exception is org.springframework.core.ConstantException: Field '${SYSTEM_PROPERTIES_MODE_OVERRIDE}' not found in class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1453)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1158) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) 
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:657) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461) 
at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:128) 
at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:60) 
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100) 
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:248) 
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64) 
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91) 
... 32 more 
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: 
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'systemPropertiesModeName' threw exception; nested exception is org.springframework.core.ConstantException: Field '${SYSTEM_PROPERTIES_MODE_OVERRIDE}' not found in class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] 
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:101) 
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1450)
... 47 more 

Your problem is that ${SYSTEM_PROPERTIES_MODE_OVERRIDE} is a placeholder and since you are still creating the PropertyPlaceholderConfigurer it cannot be resolved. 您的问题是${SYSTEM_PROPERTIES_MODE_OVERRIDE}是一个占位符,由于您仍在创建PropertyPlaceholderConfigurer因此无法解决。

It must be a typo, you should use 必须是错字,应该使用

<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/> 

the string value is converted to an int internally 字符串值在内部转换为int

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 春天的多种特性。 PropertyPlaceholderConfigurer类中的属性 - multiple properties in spring. property in PropertyPlaceholderConfigurer class Spring的PropertyPlaceholderConfigurer可以用代码而不是bean读取整个属性文件吗? - Can Spring's PropertyPlaceholderConfigurer read an entire properties file in code, not as a bean? 带有Spring PropertyPlaceholderConfigurer属性标志的IllegalArgumentException - IllegalArgumentException with Spring PropertyPlaceholderConfigurer properties flag 如何覆盖从Spring PropertyPlaceHolderConfigurer加载的特定属性? - How to override specific properties loaded from spring PropertyPlaceHolderConfigurer? 使用 Jboss 读取 PropertyPlaceholderConfigurer 类路径 Spring - Read PropertyPlaceholderConfigurer classpath Spring with Jboss 从资源和PropertyPlaceholderConfigurer的Spring RequestMapping? - Spring RequestMapping from Resources and PropertyPlaceholderConfigurer? Spring:无法使用PropertyPlaceholderConfigurer加载junit上的属性 - Spring: can't load properties on junit with PropertyPlaceholderConfigurer 打印通过Spring PropertyPlaceholderConfigurer设置的所有属性 - Printing all properties set via Spring PropertyPlaceholderConfigurer Spring PropertyPlaceholderConfigurer从DB加载 - Spring PropertyPlaceholderConfigurer load from DB 如何使用Spring PropertyPlaceholderConfigurer从另一个属性文件调用属性文件? - How to call properties file from another properties file using Spring PropertyPlaceholderConfigurer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM