2015-10-28 2 views
0
<?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> 

у меня есть этот XML, через которые я должен читать SYSTEM_PROPERTIES_MODE_OVERRIDE из класса PropertyPlaceholderConfigurer, но я получаю это исключение. У меня есть этот xml, через который я должен прочитать SYSTEM_PROPERTIES_MODE_OVERRIDE из класса PropertyPlaceholderConfigurer, но я получаю это исключение. У меня есть этот xml, через который я должен прочитать SYSTEM_PROPERTIES_MODE_OVERRIDE из класса PropertyPlaceholderConfigurer, но я получаю это исключение.не умеет читать свойства из класса весной PropertyPlaceholderConfigurer

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 

ответ

0

Ваша проблема заключается в том, что ${SYSTEM_PROPERTIES_MODE_OVERRIDE} является заполнителем и так как вы все еще создает PropertyPlaceholderConfigurer она не может быть решена.

Должно быть опечатка, вы должны использовать

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

значение строки превращают в ИНТ internally

+0

пытался, но та же ошибка – saurabh

+0

В сообщении об ошибке вы имели $ {SYSTEM_PROPERTIES_MODE_OVERRIDE} Теперь, когда вы изменил его на SYSTEM_PROPERTIES_MODE_OVERRIDE, как может быть такая же ошибка, вы уверены? Повторяется ли это «Поле» $ {SYSTEM_PROPERTIES_MODE_OVERRIDE} 'не найдено в классе [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] "? –

Смежные вопросы