parse data from Nacos error

SpringCloud Alibaba reads configuration files from Nacos.
Running in the development tool, there is no problem, and it starts normally.

After packaging, the jar package starts java -jar application-1.0.0.jar, and an error occurs:

ERROR - [main] c.a.c.n.c.NacosPropertySourceBuilder : parse data from Nacos error,dataId:application-dev.yml,data:spring:
...
org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1

problem causes:

The encoding of the configuration content is inconsistent.
There is Chinese in the configuration file, and nacos defaults to utf-8 when reading the configuration file, and gbk is used by default to start the project through cmd.

Solution:

Specify the encoding format at startup, -Dfile.encoding=utf-8 .

java -jar -Dfile.encoding=utf-8 -Dserver.port=8080  application-1.0.0.jar

Guess you like

Origin blog.csdn.net/qgbihc/article/details/115767979