idea启动正常,jar启动报错 Caused by: java.nio.charset.MalformedInputException: Input length = 1

起因:项目在idea中启动时没有问题,但是打包后java -jar启动时确报错了


org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1
        at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:218) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:171) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:126) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1177) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:287) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:227) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.produce(ParserImpl.java:195) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:148) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.composer.Composer.checkNode(Composer.java:82) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.constructor.BaseConstructor.checkData(BaseConstructor.java:123) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.Yaml$1.hasNext(Yaml.java:489) ~[snakeyaml-1.26.jar!/:na]
        at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:200) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
        at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:164) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
        at org.springframework.beans.factory.config.YamlMapFactoryBean.createMap(YamlMapFactoryBean.java:124) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
        at org.springframework.beans.factory.config.YamlMapFactoryBean.getObject(YamlMapFactoryBean.java:104) ~[spring-beans-5.2.7.RELEASE.jar!/:5.2.7.RELEASE]
        at com.alibaba.cloud.nacos.parser.NacosDataYamlParser.doParse(NacosDataYamlParser.java:40) ~[spring-cloud-starter-alibaba-nacos-config-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
        at com.alibaba.cloud.nacos.parser.AbstractNacosDataParser.parseNacosData(AbstractNacosDataParser.java:80) ~[spring-cloud-starter-alibaba-nacos-config-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
        at com.alibaba.cloud.nacos.parser.AbstractNacosDataParser.parseNacosData(AbstractNacosDataParser.java:85) ~[spring-cloud-starter-alibaba-nacos-config-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
        at com.alibaba.cloud.nacos.parser.NacosDataParserHandler.parseNacosData(NacosDataParserHandler.java:45) ~[spring-cloud-starter-alibaba-nacos-config-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
        at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.loadNacosData(NacosPropertySourceBuilder.java:98) [spring-cloud-starter-alibaba-nacos-config-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
        at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.build(NacosPropertySourceBuilder.java:74) [spring-cloud-starter-alibaba-nacos-config-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
        at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosPropertySource(NacosPropertySourceLocator.java:204) [spring-cloud-starter-alibaba-nacos-config-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
        at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosDataIfPresent(NacosPropertySourceLocator.java:191) [spring-cloud-starter-alibaba-nacos-config-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
        at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadApplicationConfiguration(NacosPropertySourceLocator.java:142) [spring-cloud-starter-alibaba-nacos-config-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
        at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.locate(NacosPropertySourceLocator.java:103) [spring-cloud-starter-alibaba-nacos-config-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
        at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:52) [spring-cloud-context-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:47) [spring-cloud-context-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:98) [spring-cloud-context-2.2.5.RELEASE.jar!/:2.2.5.RELEASE]
        at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:626) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
        at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:370) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
        at com.putao.gateway.GatewayApplication.main(GatewayApplication.java:16) [classes!/:1.0.0]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_152]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_152]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_152]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_152]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [xiaoyou-gateway-1.0.0.jar:1.0.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:109) [xiaoyou-gateway-1.0.0.jar:1.0.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [xiaoyou-gateway-1.0.0.jar:1.0.0]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [xiaoyou-gateway-1.0.0.jar:1.0.0]
Caused by: java.nio.charset.MalformedInputException: Input length = 1
        at java.nio.charset.CoderResult.throwException(CoderResult.java:281) ~[na:1.8.0_152]
        at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339) ~[na:1.8.0_152]
        at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) ~[na:1.8.0_152]
        at java.io.InputStreamReader.read(InputStreamReader.java:184) ~[na:1.8.0_152]
        at org.yaml.snakeyaml.reader.UnicodeReader.read(UnicodeReader.java:125) ~[snakeyaml-1.26.jar!/:na]
        at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:183) ~[snakeyaml-1.26.jar!/:na]
        ... 43 common frames omitted

jar包启动报错截图

原因:存在中文,编码问题
启动命令改为下面即可

java -Dfile.encoding=utf-8 -jar  xxx.jar
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值