Intellij IDEA 中运行正常,linux 运行正常, cmd 下运行 报:MalformedInputException: Input length = 1
微服务项目,在Nacos中做了配置,在引用 Nacos中配置时,编码问题,导致的错误
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:507)
解决方法:
java -Dfile.encoding=utf-8 -jar vipsoft.jar
加上: -Dfile.encoding=utf-8 注意 -jar xxx 要放最后,否则 -D参数不生效
标签:MalformedInputException,Java,java,snakeyaml,jar,yaml,ScannerImpl,org,StreamReade From: https://www.cnblogs.com/vipsoft/p/16869444.html