2017-10-27 12 views
1

시스템 속성으로 구성을 설정하는 핵심 라이브러리가 있습니다. 이것은 단위 테스트에서 작동Typesafe Config는 런타임에 설정된 시스템 속성을 사용하지 않습니다.

my.mail.from = "[email protected]" 
my.mail.from = ${?mail.from} 

:

mail.from = [email protected] 

내가 좋아하는, 그들과 함께 내 설정을 무시하고 싶었다. 내 Play (2.6) 응용 프로그램에서는 그렇지 않습니다.

PropertiesConfiguration.init() // this inits the system properties 
info("mail.from: " + sys.props.get("mail.from")) // >> '[email protected]' as expected 
val config = ConfigFactory.load() 
info("my.mail.from: " + config.getString("my.mail.from")) // >> '[email protected]' instead of '[email protected]' 

이 작업을 수행 할 수 없나요?

답변

4

시스템 등록 정보의 변경 픽업하기 위해 캐쉬 구성을 무효화하십시오 :

PropertiesConfiguration.init() 
info("mail.from: " + sys.props.get("mail.from")) 

ConfigFactory.invalidateCaches() 

val config = ConfigFactory.load() 
info("my.mail.from: " + config.getString("my.mail.from"))