简体   繁体   中英

Difference between equals and colon in Java properties file

In spring, you can have different properties files in order to configure the messages, so they tend to be something like this:

message.key=text here
another.message.key=another text here

But today I saw in a project that it was using this format:

message.key:text here
another.message.key:another text here

I think this applies to any Java properties file, but what is the difference if any?

If you were really talking about standard Java Properties files, there is no difference between a colon and an equals sign. Either can delimit a key from its value. In fact, you could even mix them in the same file, if you want to annoy readers.

The documents are in different formats.

The first one is the normal properties format.

The second document is in the YAML language.

The YAML data will be translated to properties when used by Spring. So both formats have exactly the same result. See https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-yaml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM