我的Osgi捆绑包中有config.properties.但是Osgi捆绑包无法读取它.
Application context refresh Failed (OsgiBundleXmlApplicationContext(bundle=dao,config=osgibundle:/meta-inf/spring/*.xml))
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException
我正在使用Spring来读取config.properties
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="config.properties" />
</bean>
最佳答案
您必须为value属性指定正确的资源.
有一些built in implementations,例如:
有一些built in implementations,例如:
> ClassPathResource:value =“ classpath:/meta-inf/config.properties”
> FileSystemResource:value =“ file:C:/foobar/config.properties”
如果要将文件放置在库外,则可以使用系统属性(例如-DpropertyFile = C:/loremIpsum/config.properties)来指定路径,例如
value="file:${propertyFile}"
从Spring 3.0开始.即使具有默认值
value="file:${propertyFile:C:/foobar/config.properties}"
(有关如何设置系统属性的信息,请查看您的Osgi框架.我也不确定ClassPathResource是否运行良好/是否建议在Osgi环境中使用.)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。