java复制spring属性文件
我有两个spring属性文件,一个用于集成测试,另一个用于实际项目。属性文件基本相同,但在测试属性文件中,我有两个不同的属性用于测试目的。这是一个维护难题,每次我添加属性时,我都必须将其复制到测试属性文件中,即使它完全相同。我只是在测试中遇到了一个bug,这是因为测试属性文件没有更新
我有一个application-context-test.xml
从项目application-context.xml
导入了很多bean,但是覆盖了出于测试目的需要的bean,我可以对属性文件做同样的操作吗
以下是我的属性文件配置
application-context.xml
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:myproject.properties"/>
</bean>
application-context-test.xml
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:myproject-test.properties"/>
</bean>
# 1 楼答案
您可以创建两个具有不同属性的文件,并按如下方式加载这两个文件: