【发布时间】:2012-03-24 09:41:23
【问题描述】:
我正在使用 Spring 开发一个命令行 Java 应用程序。我有多个属性文件存储在不同的位置,一个属性文件包含所有这些属性的路径。我正在使用 PropertyPlaceholderConfigurer 来读取包含不同属性文件位置的属性。我不确定处理多个属性的最佳方式。
应用程序的工作方式如下:我将使用 JVM 命令 -Dmypath=parent.properties 传递第一个属性文件的路径。属性文件将如下所示:
child1=/location1/child1.properties
child2=/location2/child2.properties
以此类推
我的父属性配置如下所示:
<bean id="parentProperty" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>${mypath}</value>
</list>
</property>
</bean>
child1 配置看起来:
<bean id="child1Property" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>${child1}</value>
</list>
</property>
</bean>
现在当我调用 child1 时,它无法加载属性。
【问题讨论】:
标签: java spring properties