【发布时间】:2016-07-24 22:43:36
【问题描述】:
我需要使用 Java.util.properties 而不是 Spring Eg 中的 PropertyPlaceHolderConfigurator 来动态放置 springbeans.xml 中的属性值。
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="file:test.properties" />
</bean>
<bean id="dbconnectionFactory" class="com.test.Test">
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</bean>
我可以使用 java.util.properties 来模拟相同的结果,即
<bean id="javaproperty" class="java.util.Properties">
<property name="location" value="file:test.properties" />
</bean>
<bean id="dbconnectionFactory"
class="con.test.Test">
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</bean>
【问题讨论】:
-
你为什么需要这个,你能解释一下你为什么不想要或者可以使用
PropertyPlaceHolderConfigurer吗?
标签: java spring properties spring-properties