简体   繁体   English

Java属性文件中equals和冒号之间的区别

[英]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: 在Spring中,您可以使用不同的属性文件来配置消息,因此它们往往是这样的:

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? 我认为这适用于任何Java属性文件,但有什么区别?

If you were really talking about standard Java Properties files, there is no difference between a colon and an equals sign. 如果您真的在谈论标准Java Properties文件,则冒号和等号之间没有区别。 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. 第二个文件是YAML语言。

The YAML data will be translated to properties when used by Spring. 当Spring使用时,YAML数据将被转换为属性。 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 请参阅https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-yaml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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