2017-03-20 17 views
2

Apache Commons Configuration의 경우 여러 Java 등록 정보 파일을로드하려고합니다.Apache Commons 구성 파일 가져 오기 파일

다른 파일을 하나의 파일에 "가져 오기/포함"할 수 있는지 궁금해서 첫 번째 파일 만로드하면됩니다. 나머지는 모두 가져옵니다.

예.

propertyA=10 
propertyB=20 
propertyC=30 
propertyD=40 
현재

, 난 그냥

을 사용하고

common.properties

include 'specific.properties' 
propertyA=10 
propertyB=20 

specific.properties

propertyC=30 
propertyD=40 

그래서 결국 나는 것
CompositeConfiguration config = new CompositeConfiguration(); 
config.addConfiguration(new PropertiesConfiguration("common.properties")); 
config.addConfiguration(new PropertiesConfiguration("specific.properties")); 

미리 감사드립니다.

답변

1

가능합니다. 이 문서에서 복사 : 속성의 이름은

경우 "포함"및 해당 속성의 값이 디스크에있는 파일의 이름이며,이 파일은 구성에 포함됩니다.

귀하의 경우에는

(common.properties) :

include = specific.properties 
propertyA = 10 
propertyB = 20 

specific.properties

propertyC = 30 
propertyD = 40 

는 여기를 참조하십시오 https://commons.apache.org/proper/commons-configuration/userguide/howto_properties.html#Using_PropertiesConfiguration

+0

감사합니다! 정확히 내가 필요로하는 것 – Henry