本篇内容主要讲解“SpringCloud启动失败问题如何解决”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“SpringCloud启动失败问题如何解决”吧!
SpringCloud启动失败问题
Nacos配置读取失败
org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1
at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:218) ~[snakeyaml-1.27.jar!/:na]
at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176) ~[snakeyaml-1.27.jar!/:na]
at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:171) ~[snakeyaml-1.27.jar!/:na]
at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:126) ~[snakeyaml-1.27.jar!/:na]
at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1177) ~[snakeyaml-1.27.jar!/:na]
at org.yaml.snakeyaml.constructor.BaseConstructor.checkData(BaseConstructor.java:123) ~[snakeyaml-1.27.jar!/:na]
at org.yaml.snakeyaml.Yaml$1.hasNext(Yaml.java:507) ~[snakeyaml-1.27.jar!/:na]
at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:198) ~[spring-beans-5.3.8.jar!/:5.3.8]
at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:166) ~[spring-beans-5.3.8.jar!/:5.3.8]
at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosPropertySource(NacosPropertySourceLocator.java:199) [spring-cloud-starter-alibaba-nacos-config-2021.1.jar!/:2021.1]
com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadExtConfiguration(NacosPropertySourceLocator.java:128) [spring-cloud-starter-alibaba-nacos-config-2021.1.jar!/:2021.1]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [app.jar:1.0.0]
Caused by: java.nio.charset.MalformedInputException: Input length = 1
at java.nio.charset.CoderResult.throwException(UnkNown Source) ~[na:1.8.0_311]
at sun.nio.cs.StreamDecoder.implRead(UnkNown Source) ~[na:1.8.0_311]
at sun.nio.cs.StreamDecoder.read(UnkNown Source) ~[na:1.8.0_311]
at java.io.InputStreamReader.read(UnkNown Source) ~[na:1.8.0_311]
at org.yaml.snakeyaml.reader.UnicodeReader.read(UnicodeReader.java:125) ~[snakeyaml-1.27.jar!/:na]
at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:183) ~[snakeyaml-1.27.jar!/:na]
... 41 common frames omitted
2022-02-24 15:50:08.897 ERROR 39048 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : parse data from Nacos error,dataId:dbsource.yml,data:spring:
main:
allow-bean-deFinition-overriding: true
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
login-username: admin
login-password: admin
reset-enable: false
Root cause:
编码不一致,nacos读取配置文件时默认编码为utf-8,而通过cmd启动项目默认使用gbk。
解决方案
添加-Dfile.encoding=utf-8 启动参数
java -Dfile.encoding=utf-8 -jar app.jar
到此,相信大家对“SpringCloud启动失败问题如何解决”有了更深的了解,不妨来实际操作一番吧!这里是编程之家网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。