@H_403_1@我的OSGi捆绑包中有config.properties.但是OSGi捆绑包无法读取它.
@H_403_1@
有人有什么主意吗?
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
@H_403_1@我正在使用Spring来读取config.properties
@H_403_1@
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="config.properties" />
</bean>
@H_403_1@似乎OSGi只读取.xml文件.有人有什么主意吗?
最佳答案
您必须为value属性指定正确的资源.
有一些built in implementations,例如: @H_403_1@> ClassPathResource:value =“ classpath:/Meta-INF/config.properties”
> FileSystemResource:value =“ file:C:/foobar/config.properties” @H_403_1@如果要将文件放置在库外,则可以使用系统属性(例如-DpropertyFile = C:/loremIpsum/config.properties)来指定路径,例如 @H_403_1@
原文链接:https://www.f2er.com/spring/531802.html有一些built in implementations,例如: @H_403_1@> ClassPathResource:value =“ classpath:/Meta-INF/config.properties”
> FileSystemResource:value =“ file:C:/foobar/config.properties” @H_403_1@如果要将文件放置在库外,则可以使用系统属性(例如-DpropertyFile = C:/loremIpsum/config.properties)来指定路径,例如 @H_403_1@
value="file:${propertyFile}"
@H_403_1@从Spring 3.0开始.即使具有默认值
@H_403_1@
value="file:${propertyFile:C:/foobar/config.properties}"
@H_403_1@(有关如何设置系统属性的信息,请查看您的OSGi框架.我也不确定ClassPathResource是否运行良好/是否建议在OSGi环境中使用.)