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.
三种格式文件比较 .properties .conf .json
原文:http://blog.csdn.net/wangjuntytl/article/details/44062431