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

如何在Java中实现动态引用配置?,java,configuration,yaml,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 n

我有一个类似这样的配置(
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作为配置文件类型。

您可以使用Apache配置或Commons配置谢谢,Commons配置工作得非常好