IDEA2020.2 版本,运行SpringBoot项目时,报yml语法错误。

同样的一个Springboot项目,在IDEA 2019.3版本运行没问题,在IDEA 2020.2版本,点击运行,报以下错误:

022-04-28 09:37:09.737 ERROR   --- [main] o.s.boot.SpringApplication               : Application run failed

org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1

at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:218)

at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176)

at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:171)

at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:126)

at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1198)

at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:308)

at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:248)

at org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.produce(ParserImpl.java:213)

at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:165)

at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:155)

at org.yaml.snakeyaml.composer.Composer.checkNode(Composer.java:93)

at org.yaml.snakeyaml.constructor.BaseConstructor.checkData(BaseConstructor.java:124)

at org.yaml.snakeyaml.Yaml$1.hasNext(Yaml.java:509)

at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:198)

at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:166)

at org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:84)

at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:50)

at org.springframework.boot.context.config.StandardConfigDataLoader.load(StandardConfigDataLoader.java:54)

at org.springframework.boot.context.config.StandardConfigDataLoader.load(StandardConfigDataLoader.java:36)

at org.springframework.boot.context.config.ConfigDataLoaders.load(ConfigDataLoaders.java:107)

at org.springframework.boot.context.config.ConfigDataImporter.load(ConfigDataImporter.java:128)

at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:86)

at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:116)

at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:240)

at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:227)

at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:102)

at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:94)

at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:102)

at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:87)

at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)

at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)

at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)

at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)

at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85)

at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66)

at java.util.ArrayList.forEach(ArrayList.java:1257)

at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120)

at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114)

at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)

at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:339)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:297)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)

at co.yixiang.AppRun.main(AppRun.java:35)

Caused by: java.nio.charset.MalformedInputException: Input length = 1

at java.nio.charset.CoderResult.throwException(CoderResult.java:281)

at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)

at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)

at java.io.InputStreamReader.read(InputStreamReader.java:184)

at org.yaml.snakeyaml.reader.UnicodeReader.read(UnicodeReader.java:125)

at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:183)

... 43 common frames omitted

Process finished with exit code 1

我可以保证只修改了application-dev.yml中的数据库链接信息,其余没改:

application-dev.yml:

#配置数据源

spring:

application:

name: yshop-admin

datasource:

druid:

type: com.alibaba.druid.pool.DruidDataSource

driverClassName: com.mysql.cj.jdbc.Driver

url: jdbc:mysql://localhost:3306/xiquefc_new?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true

username: root

password: root

# 初始化配置

initial-size: 3

# 最小连接数

min-idle: 3

# 最大连接数

max-active: 15

# 获取连接超时时间

max-wait: 5000

# 连接有效性检测时间

time-between-eviction-runs-millis: 90000

# 最大空闲时间

min-evictable-idle-time-millis: 1800000

test-while-idle: true

test-on-borrow: false

test-on-return: false

validation-query: select 1

# 配置监控统计拦截的filters

filters: stat

stat-view-servlet:

url-pattern: /druid/*

reset-enable: false

web-stat-filter:

url-pattern: /*

exclusions: "*.js,*.gif,*.jpg,*.bmp,*.jpg,*.css,*.ico,/druid/*"

redis:

# 地址

host: 127.0.0.1

# 端口,默认为6379

port: 6379

# 数据库索引

database: 13

# 密码

password:

# 连接超时时间

timeout: 5000

# 是否限制单用户登录

single:

login: false

#jwt

jwt:

header: Authorization

# 令牌前缀

token-start-with: Bearer

secret: k09BQnaF

# 必须使用最少88位的Base64对该令牌进行编码

base64-secret: ZmQ0ZGI5NjQ0MDQwY2I4MjMxY2Y3ZmI3MjdhN2ZmMjNhODViOTg1ZGE0NTBjMGM4NDA5NzYxMjdjOWMwYWRmZTBlZjlhNGY3ZTg4Y2U3YTE1ODVkZDU5Y2Y3OGYwZWE1NzUzNWQ2YjFjZDc0NGMxZWU2MmQ3MjY1NzJmNTE0MzI=

# 令牌过期时间 此处单位/毫秒 ,默认4小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html

token-validity-in-seconds: 14400000

# 在线用户key

online-key: online-token

# 验证码

code-key: code-key

#是否允许生成代码,生产环境设置为false

generator:

enabled: true

#是否开启 swagger-ui

swagger:

enabled: true

title: yshop商城管理后台API

serverUrl:

version: 2.3

# 文件存储路径

# 1.localUrl为空的话上传文件会走七牛云,请转向文档看七牛云配置

# 2.如果想文件存在本地,并通过本地代理出去请填写localUrl: http://127.0.0.1:8000为本服务的ip+端口号

# 线上的地址就是你通过nginx代理http://127.0.0.1:8000出来的地址。鉴于群里很多问的这里做个说明不在赘述

file:

path: D:\yshop\file\

avatar: D:\yshop\avatar\

# 文件大小 /M

maxSize: 100

avatarMaxSize: 5

localUrl: http://127.0.0.1:8000

跪求大佬翻牌。


回答:

首先尝试

macos 用option + command + L window 用ctrl + alt + L格式化一下文档

在查看
  • 你之前用旧版本IDEA打开项目的编码格式是否是UTF-8还是GBK还是其他,如果不一致修改一致
  • 推荐统一用 UTF-8

以上是 IDEA2020.2 版本,运行SpringBoot项目时,报yml语法错误。 的全部内容, 来源链接: utcz.com/p/944406.html

回到顶部