spring读取属性文件时出现404错误
我正在尝试从属性文件中读取数据。我已在 xml 中指定了路径。当我运行应用程序时,它会抛出错误 -
*org.springframework.beans.factory.BeanDefinitionStoreException: 名称为“fbStuffKeeper”的 bean 定义无效在 ServletContext 资源 [/WEB-INF/applicationContext.xml] 中定义:无法解析占位符“facebook.appId”
我的 applicationContext.xml -
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<context:component-scan base-package="com.cognizant.awcoe.bazaar.social.spring.controllers" use-default-filters="false">
<context:include-filter expression="org.springframework.stereotype.Controller" type="annotation" />
</context:component-scan>
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:/com/social/spring/config/facebook.properties"/>
</bean>
<bean id="fbStuffKeeper" class="com.social.spring.facebook.FBStuffManager">
<property name="secret" value="${facebook.appSecret}"/>
<property name="clientId" value="${facebook.appId}"/>
<property name="redirectURI" value="${redirect.uri}"/>
</bean>
</beans>
facebook.properties包含-
facebook.appID=xxxxxxxxxxxxxxxxxx
facebook.appSecret=xxxxxxxxxxxxxxxxxx
redirect.uri=http:xxxxxxxxxxxxxxxxxx
我是否正确指定了属性文件的路径。我哪里出错了? 请纠正我
I am trying to read data from properties file.I have specified the path in xml.When I run the app it throws an error -
*org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'fbStuffKeeper' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Could not resolve placeholder 'facebook.appId'
My applicationContext.xml -
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<context:component-scan base-package="com.cognizant.awcoe.bazaar.social.spring.controllers" use-default-filters="false">
<context:include-filter expression="org.springframework.stereotype.Controller" type="annotation" />
</context:component-scan>
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:/com/social/spring/config/facebook.properties"/>
</bean>
<bean id="fbStuffKeeper" class="com.social.spring.facebook.FBStuffManager">
<property name="secret" value="${facebook.appSecret}"/>
<property name="clientId" value="${facebook.appId}"/>
<property name="redirectURI" value="${redirect.uri}"/>
</bean>
</beans>
facebook.properties contain-
facebook.appID=xxxxxxxxxxxxxxxxxx
facebook.appSecret=xxxxxxxxxxxxxxxxxx
redirect.uri=http:xxxxxxxxxxxxxxxxxx
Have I specified the path of the properties file correctly..Where did I go wrong??
Kindly correct me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来像是最后一个
d
的错误情况:facebook.appId
而不是facebook.appID
Looks like a mistaken case of the last
d
:facebook.appId
instead offacebook.appID