문제

I have beans xml file, which loads multiple property files for creating its beans. All these property files are under a root folder like root/abc/abc.properties , root/xyz/some.properties etc..

<bean id="x".....
....
<util:properties id="properties" location="${config.base.dir}/abc/abc.properties" />
......
</bean>


<bean id="y".....
....
<util:properties id="properties" location="${config.base.dir}/xyz/some.properties" />
......
</bean>

I want to override put the value of config.base.dir somewhere in top so that I can keep changing the root location, should this be possible by defining some property on top?

도움이 되었습니까?

해결책

If using Maven, you can have a version of abc.properties in the test/resources/abc/ folder. this will be picked up on the classpath before the main/resources/abc/abc.properties file.

Does this help?

Why do you want to ' keep changing the root location' ?


system properties overrides...

<!-- Configuration property files -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="systemPropertiesModeName">
        <value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value>
    </property>
    <property name="locations">
        <list>
            <value>classpath*:config.properties</value>
        </list>
    </property>
</bean>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top