PropertyPlaceholderConfigurer在磁盘上找不到属性文件

时间:2012-02-05 16:16:10

标签: spring osgi blueprint

我正在尝试将工作弹簧WAR移动到OSGI环境(在glassfish 3.1和blueprint,spring 3.0.5中)。 应用程序从磁盘加载属性文件,如下所示:

<bean id="myProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="${my_conf}/my.properties"/>
    <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
</bean>

我在调试器中看到${my_conf}/my.properties已转换为现有路径(c:\ conf \ my.properties)

我在下一个bean声明

中使用jms.url中定义的属性my.properties
<amq:broker useJmx="false" persistent="false" brokerName="embeddedbroker">
    <amq:transportConnectors>
        <amq:transportConnector uri="tcp://${jms.url}"/>
        <amq:transportConnector uri="vm://embeddedbroker" />
    </amq:transportConnectors>
</amq:broker>

在部署中,我得到例外"Could not resolve placeholder ${jms.url}"

为什么会失败?是否有另一种方法从磁盘上的文件加载属性?

谢谢

2 个答案:

答案 0 :(得分:0)

由于它是一个OSGI环境,你需要在你的应用程序中添加spring-osgi-core jar。看一下这个link来配置OSGI框架的property-placeholder。

答案 1 :(得分:0)

这不是解决方案,而是对我的问题的解释。 问题与此bug in spring 3 and osgi有关。

我必须打开spring日志来调试级别才能理解它。

相关问题