首页 > 解决方案 > spring-boot--application.yml-里面如何使用特殊字符#

问题描述

使用 # 符号作为注释的 Yaml 文件

YAML 中的注释看起来像这样。

################
# SCALAR TYPES #
###############

现在在属性文件中我有以下值

根#

作为密码,但使用作为注释的 yaml 文件,我该如何跳过它。

spring:
   #data source connection
  datasource:
    url: jdbc:mysql://localhost:3306/vaquarkhan
    username: rootadmin
    password: root#

标签: spring-bootyaml

解决方案


YAML 中的特殊字符列表必须进行转义。

:, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, @, `

您可以引用字符串

"root#"

或使用反斜杠。

root\#

推荐阅读