Amb*_*ari 3 java config typesafe
我使用typesafe配置来读取一些初始配置.
有没有办法检查类型配置中是否存在密钥的一部分.例如,我有以下配置:
foo {
bar {
x = 42
y = 92
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我想检查我的conf包含foo.bar我不在乎任何配置x或y两者都存在一方的存在.
我只想检查配置中是否存在bar的配置.可能吗?
Config具有检查路径是否存在的方法
config.hasPath("foo.bar");
Run Code Online (Sandbox Code Playgroud)
鉴于以下内容
foo {
bar {
x = 42
}
}
System.out.println(config.hasPath("foo.bar"));
System.out.println(config.hasPath("foo.bar.x"));
Run Code Online (Sandbox Code Playgroud)
我明白了
true
true
Run Code Online (Sandbox Code Playgroud)
如果我删除x = 42我得到
true
false
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3012 次 |
| 最近记录: |