我试图使用PropertyPlaceholderConfigurer来读取我的应用程序配置。基本上,WEB-INF/config/config.properties
中有第一个配置文件,其中包含另一个属性文件的文件系统位置(以便在应用程序部署或更新期间不会销毁它)。我想有这个成立于servlet-context.xml
,但只有第一个作品:无法让PropertyPlaceholderConfigurer以我想要的方式工作
<bean id="propertyConfigurerInternal"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/WEB-INF/config/config.properties</value>
</property>
</bean>
<bean id="propertyConfigurerExternal"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
depends-on="propertyConfigurerInternal">
<property name="location">
<value>file:${baseDataFolder}/jaccise.conf</value>
</property>
</bean>
第一个(propertyConfigurerInternal
)是没有问题的产生,但第二个失败是这样的:
org.springframework.beans.factory.BeanInitializationException
:无法加载属性;嵌套的例外是java.io.FileNotFoundException
:${baseDataFolder}\jaccise.conf
(Impossibile trovare IL percorso specificato)< - 意思是“无法找到文件中指定的路径”
像EL表达式是不工作...我该如何解决这个问题?
我不认为你可以做到这一点。所有的'PropertyPlaceholderConfigurer' bean都被初始化,然后*然后*替换发生。所以他们不能互相指责。 – skaffman 2011-03-29 10:47:53
那么你会如何解决这样的事情? – gotch4 2011-03-29 10:49:03