当前位置:   article > 正文

org.yaml.snakeyaml.parser.ParserException_org.yaml.snakeyaml.parser.parserexception: while p

org.yaml.snakeyaml.parser.parserexception: while parsing a block collection

错误:
Caused by: org.yaml.snakeyaml.parser.ParserException: while parsing a block…
问题:yml文件格式错误
可以使用http://www.bejson.com/validators/yaml_editor/进行yml文件格式检测

我的结果总是显示缩进错误YAMLException: bad indentation of a mapping entry,比如:

spring:
  datasource:
driverClassName: com.mysql.cj.jdbc.Driver
#url: jdbc:mysql://127.0.0.1:3306/XXX?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
          url: jdbc:mysql://localhost:3307/XXX?useSSL=false&useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
        #url: jdbc:h2:file:./data/h2db
          username : XXX
          password : XXX
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

这是错误的,我把注释都删掉,并且把URL和username和password的缩进对齐,就不报错了。
也是很神奇。
正确格式:

spring:
  datasource:
    #      driverClassName: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3307/XXX?useSSL=false&useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
    #        url : jdbc:h2:file:./data/h2db
    username : XXX
    password : XXX
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/271398
推荐阅读
相关标签
  

闽ICP备14008679号