我已經配置類似下面春天ignoreResourceNotFound不工作
<bean id="applicationHostProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true"></property>
<property name="locations">
<list>
<value>classpath:applicationHost.properties</value>
</list>
</property>
</bean>
從我的Spring bean我注入屬性文件
@Value("#{appsDeployedProperties}")
private Properties appsDeployedProperties;
既然我已經設置ignoreResourceNotFound =真屬性文件,如果找不到屬性文件,我不期待任何錯誤。
但是我的春天上下文初始化失敗,如果屬性文件丟失。我在這裏做錯了什麼?謝謝你的幫助。
錯誤堆棧跟蹤:
錯誤名爲 '上instanceConfigurati ' 創建豆:不滿意依賴通過現場 'appsDeployedProperties' 表示:前 PRESSION解析失敗;嵌套的異常是org.springframework.expression.spel .SpelEvaluationException:EL1008E:(pos 0):屬性或字段'appsDeployedProper ties'無法在類型爲'org.springframework.beans.factory.confi的對象上找到 g.BeanExpressionContext ' - 也許不公開?嵌套異常是org.springfram ework.beans.factory.BeanExpressionException:表達式解析失敗;嵌套e xception is org.springframework.expression.spel.SpelEvaluationException:EL1008E :(pos 0):無法在對象上找到屬性或字段'appsDeployedProperties' f type'org.springframework.beans.factory.config.BeanExpressionContext ' - 也許 不公開?嵌套的異常是org.springframework.beans.factory.UnsatisfiedDe pendencyException:創建名爲'instanceConfiguration'的bean時出錯:Unsati 通過字段'appsDeployedProperties'表示的已滿依賴:表達式pa 解析失敗;嵌套異常是org.springframework.expression.spel.SpelEvalua tionException:EL1008E:(pos 0):屬性或字段'appsDeployedProperties'canno 在類型'org.springframework.beans.factory.config.BeanExpre ssionContext' - 可能不公開?嵌套異常是org.springframework.beans .factory.BeanExpressionException:表達式解析失敗;嵌套的異常是 org.springframework.expression.spel.SpelEvaluationException:EL1008E:(pos 0):P roperty或字段'appsDeployedProperties'無法在'org類型的對象上找到' .springframework.beans.factory.config.BeanExpressionContext' - 可能不公開?在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP ostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.j ava:569)〜[spring-beans-4.3.2.RELEASE.jar!/:4.3 .2.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject (InjectionMetadata.java:88)〜[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP 個ostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java :349)〜[彈簧豆-4.3.2.RELEASE.jar /:4.3.2.RELEASE]
添加堆棧跟蹤,請 – Jens
添加了錯誤的堆棧跟蹤 – lives
可以請你重新設置堆棧跟蹤,它不是以這種形式可讀 – Jens