当配置文件中有中文时,springboot服务读取nacos配置启动报错:
1  | ERROR 9740 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : parse data from Nacos error,dataId:xxxxxxxxxxxxxx.yaml,data:server:  | 
环境
- windwos 11 21H2
 - IntelliJ IDEA 2022.3.2 (Community Edition)
 - NACOS 2.2.0
 - JAVA 1.8
 - springboot
 
解决
使用java -jar运行
启动命令添加jvm参数: -Dfile.encoding=utf-8
1  | java -jar -Dfile.encoding=utf-8 xxx.jar  | 
使用springboot::run运行
在Springboot启动命令里添加jvm参数:-Dfile.encoding=utf-8
1  | spring-boot:run -Dspring-boot.run.jvmArguments=-Dfile.encoding=utf-8 -f pom.xml  | 
在idea里配置如下