Spring 3.0的无法加载性能 [英] Spring 3.0 Could not load properties
问题描述
林在部署Web应用程序时收到以下错误/异常:
Im the getting the following Error/exception when deploying web app:
org.springframework.beans.factory.BeanInitializationException:莫非
无法加载性能;嵌套的例外是
java.io.FileNotFoundException:无法打开ServletContext的资源
[/ WEB-INF / WebAppProps]
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/WebAppProps]
下面是即时通讯使用的背景标签的的applicationContext.xml 以指向 WebAppsProps.properties 文件
Below is the context tag that Im using in applicationContext.xml to point to WebAppsProps.properties file
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="classpath:/WEB-INF/WebAppProps.properties" />
我也用:
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/WebAppProps.properties" />
该文件是actualy在文件系统和放大器;下面是我的项目结构的快照:
The file is actualy in the filesystem & below is the snapshot of my project structure:
我也试过,把WebAppProps.properties在类路径上和利用这些变化2
I also tried , putting "WebAppProps.properties" on the classpath and used these 2 variations
变化1:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:WebAppProps.properties</value>
</property>
</bean>
2的变化:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>WebAppProps.properties</value>
</property>
</bean>
请参见下文:
Please see below:
但进出口仍然得到同样的错误/异常。
However Im still getting same error/exception.
请大家指教
感谢您
推荐答案
同样的问题,我划线,
修正:
解决方案
你的bean象下面这样:
Fix: Solution your bean like below:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/WEB-INF/database.properties</value>
</property>
</bean>
在 WEB-INF
它看起来像 WEB-INF /属性/ database.properties创建文件夹属性
因为类 PropertyPlaceholderConfigurer
默认搜索性能第一文件夹下的 / WEB-INF /
所以串联文件名作为路径
because the class PropertyPlaceholderConfigurer
default search properties folder first under /WEB-INF/
so it concatenate your file name as path
这篇关于Spring 3.0的无法加载性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!