如何在Java中实现动态引用配置?

时间:2014-03-08 15:11:12

标签: java configuration yaml

我有一个类似

的配置(config.properties
app.rootDir=
app.reportDir=${app.rootDir}/report

app.rootDir不是固定参数,必须由外部模块初始化。我需要保持${app.reportDir}保持对${app.rootDir}的动态引用。 使用伪代码来说明问题:

// Init the root dir as '/usr/app'
config.setValue('app.rootDir','/usr/app');

// I need the reportDir to be '/usr/app/report'
String reportDir = config.getValue('app.reportDir'); 

我可以编写一些代码来获取此功能,但我想知道是否有任何现有的库这样做?

根据库的可用性,我可以使用属性,yaml或json作为配置文件类型。

0 个答案:

没有答案