The three file formats each have advantages.
- Java
.properties:- Java standard, built in to JVM
- Supported by many tools such as IDEs
- JSON:
- easy to generate programmatically
- well-defined and standard
- bad for human maintenance, with no way to write comments, and no mechanisms to avoid duplication of similar config sections
- HOCON/
.conf:- nice for humans to read, type, and maintain, with more lenient syntax
- built-in tools to avoid cut-and-paste
- ways to refer to the system environment, such as system properties and environment variables
The idea would be to use JSON if you're writing a script to spit out config, and use HOCON if you're maintaining config by hand. If you're doing both, then mix the two.
本文探讨了三种常见的配置文件格式:Java .properties、JSON 和 HOCON 的优势与不足。.properties 作为 Java 标准易于集成;JSON 适合程序生成但不易手动维护;HOCON 对人类友好且支持环境变量引用。
2000

被折叠的 条评论
为什么被折叠?



