三种格式文件比较 .properties .conf .json
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.
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。