2012-01-24 44 views
0

我想要訪問我創建使用動態邏輯來確定要使用的屬性文件的Grails屬性。Grails配置 - 正確的方式來動態確定配置屬性

這是簡化的示例:

字符串pathToKey = 「Level1.Level2.Level3」

斷言config.rootProperties [pathToKey] .KEY ##返回空鍵值 斷言config.rootProperties.Level1 .Level2.Level3.key ##返回正確的密鑰值

創建多級別/對象配置文件並動態訪問密鑰的正確方法是什麼?

回答

0

我發現我一直在尋找的解決方案:

String pathAndKey = "rootProperties.Level1.Level2.Level3.key" 

String value = config.flatten().getProperty(pathAndKey)