使用命令Java -jar ****.jar,运行jar包,报错如下,刚好是配置文件有中文的,虽然中文行是 用# 注释掉了,但是依然报错:
11:28:36.401 [main] ERROR c.a.c.n.c.NacosPropertySourceBuilder - [loadNacosData,104] - parse data from Nacos error,dataId:application-dev.yml,data:spring:
main:
allow-bean-definition-overriding: true
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
mvc:
pathmatch:
matching-strategy: ant_path_matcher
# feign 配置
feign:
sentinel:
enabled: true
okhttp:
enabled: true
httpclient:
enabled: false
client:
config:
default:
connectTimeout: 10000
readTimeout: 10000
compression:
request:
enabled: true
response:
enabled: true
# 暴露监控端点
management:
endpoints:
web:
exposure:
include: '*'
org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1
at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:218)
解决方法:启动命令指定utf-8的编码,启动正常
java -jar -Dfile.encoding=UTF-8 *****.jar