yaml文件中星号(*)有什么用?
What is the use of star(*) in yaml file?
当我偶然发现这句话时,我正在检查 spring 引导执行器:
*
has a special meaning in YAML, so be sure to add quotes if you want to include (or exclude) all endpoints.
我试图通过互联网查看有关它的信息,但没有任何运气。 yaml文件中*
有什么用?
*
用于去除重复节点。考虑这个 yaml 示例:
myprop:
uid: &id XXX
myprop1:
id: *id
以上将展开为:
myprop:
uid: XXX
myprop1:
id: XXX
现在尝试 运行 此代码:
@Value("${myprop.uid}") String uid;
@Value("${myprop1.id}") String id;
@Bean
ApplicationRunner runner() {
return args -> {
System.out.println(uid); // prints "XXX"
System.out.println(id); // prints "XXX"
System.out.println(uid.equals(id)); // prints "true"
};
}
来自spec:
Repeated nodes (objects) are first identified by an anchor (marked with the ampersand - “&”), and are then aliased (referenced with an asterisk - “*”) thereafter.
这取决于 YAML 文件的上下文。你说你 正在经历 spring 引导执行器 ,所以你可以查看 Spring 引导的参考文档,第 5.2.2. Exposing Endpoints 章准确地说。
*
can be used to select all endpoints. For example, to expose everything over HTTP except the env and beans endpoints, use the following properties:
management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env,beans
星号*
表示所有属于某个类别的端点被包含或排除。
下面的句子只是说星号 *
字符必须被引用 "*"
如果 YAML 格式使用经典属性文件。
*
has a special meaning in YAML, so be sure to add quotes if you want to include (or exclude) all endpoints, as shown in the following example:
顺便说一句,这句话与您在问题中找到的相同。
当我偶然发现这句话时,我正在检查 spring 引导执行器:
*
has a special meaning in YAML, so be sure to add quotes if you want to include (or exclude) all endpoints.
我试图通过互联网查看有关它的信息,但没有任何运气。 yaml文件中*
有什么用?
*
用于去除重复节点。考虑这个 yaml 示例:
myprop:
uid: &id XXX
myprop1:
id: *id
以上将展开为:
myprop:
uid: XXX
myprop1:
id: XXX
现在尝试 运行 此代码:
@Value("${myprop.uid}") String uid;
@Value("${myprop1.id}") String id;
@Bean
ApplicationRunner runner() {
return args -> {
System.out.println(uid); // prints "XXX"
System.out.println(id); // prints "XXX"
System.out.println(uid.equals(id)); // prints "true"
};
}
来自spec:
Repeated nodes (objects) are first identified by an anchor (marked with the ampersand - “&”), and are then aliased (referenced with an asterisk - “*”) thereafter.
这取决于 YAML 文件的上下文。你说你 正在经历 spring 引导执行器 ,所以你可以查看 Spring 引导的参考文档,第 5.2.2. Exposing Endpoints 章准确地说。
*
can be used to select all endpoints. For example, to expose everything over HTTP except the env and beans endpoints, use the following properties:management.endpoints.web.exposure.include=* management.endpoints.web.exposure.exclude=env,beans
星号*
表示所有属于某个类别的端点被包含或排除。
下面的句子只是说星号 *
字符必须被引用 "*"
如果 YAML 格式使用经典属性文件。
*
has a special meaning in YAML, so be sure to add quotes if you want to include (or exclude) all endpoints, as shown in the following example:
顺便说一句,这句话与您在问题中找到的相同。