org.yaml.snakeyaml.scanner.ScannerException: while scanning a simple key 报错解决方法
org.yaml.snakeyaml.scanner.ScannerException: while scanning a simple key 报错解决方法
报错信息如下:
13:31:17.438 [main] ERROR org.springframework.boot.SpringApplication - Application run failed org.yaml.snakeyaml.scanner.ScannerException: while scanning a simple key in 'reader', line 16, column 1: jsonFile: ^ could not find expected ':' in 'reader', line 17, column 5: #encoding: "GBK" ^ at org.yaml.snakeyaml.scanner.ScannerImpl.stalePossibleSimpleKeys(ScannerImpl.java:484) at org.yaml.snakeyaml.scanner.ScannerImpl.needMoreTokens(ScannerImpl.java:299) at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:247) at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:602) at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:165)
解决方法:
在 application.yml 文件键值之间要用冒号:隔开,而且冒号和值之间有一个空格,否则就报上面的错误!
错误写法:
encoding:true
正确写法:
encoding: true
而我呢是在开始的时候就给了个空格,导致报错。
错误展示:
正确展示: