启动springboot时收到以下错误消息:
Caused by: org.yaml.snakeyaml.parser.ParserException: while parsing a block mapping
in 'reader', line 23, column 9:
trust-store: file:keystore.jks
^
expected <block end>, but found Scalar
in 'reader', line 24, column 37:
key-store-password: {cipher}0b544ca0afbcd904c687d902d95b4db4 ...
我的bootstrap.yml
是:
spring:
application:
name: tdev-wssc-configserver
cloud:
vault:
enabled: true
host: ${vault_server_host:localhost}
port: ${vault_server_port:8200}
scheme: ${vault_server_scheme:https}
connection-timeout: 5000
read-timeout: 15000
fail-fast: true
config:
order: -10
ssl:
trust-store: file:keystore.jks
trust-store-password: {cipher}0b544ca0afbcd904c687d902d95b4db415f6309cbae49442800c2b77c02c4acf
如您所见,我正在尝试加密密钥存储区密码。
有什么想法吗?
答案 0 :(得分:2)
此错误与密码无关,而是由于花括号在YAML中具有特殊含义这一事实。基本上,Spring(或snakeyaml)无法解析YAML文件(因此ParserException
)。
要解决此特定问题,您需要将属性包装在引号中,例如:
spring:
application:
name: tdev-wssc-configserver
cloud:
vault:
enabled: true
connection-timeout: 5000
read-timeout: 15000
fail-fast: true
config:
order: -10
ssl:
trust-store: file:keystore.jks
# Add quotes
trust-store-password: '{cipher}0b544ca0afbcd904c687d902d95b4db415f6309cbae49442800c2b77c02c4acf'
the documentation中也对此进行了演示,您可以在application.yml
中看到使用了其他引号,而在application.properties
中则不需要这些引号。