大坑:在使用nacos作为微服务的配置中心时,想要动态发布配置到多环境的微服务当中去,将服务发布jar包后,在本地命令窗口运行jar包时报错,在idea中运行的很欢,但是到命令窗口就不行了:遇到各种问题:
Description:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
或者这种错误
或者这种:
Caused by: org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1
at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:200)
at org.yaml.snakeyaml.reader.StreamReader.<init>(StreamReader.java:60)
at org.yaml.snakeyaml.Yaml.loadAll(Yaml.java:463)
at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:160)
at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:138)
at
问题原因:编码不一致,nacos读取配置文件时默认编码为utf-8,而通过cmd启动项目默认使用gbk。
解决办法:指定编码格式
java -jar -Dfile.encoding=utf-8 xxx.jar