Spring-启动可执行编码
Spring-Boot executable encoding
我的 Rest-Application 在 Eclipse 下 运行 时以正确的编码传送数据。但是当我在 Windows 系统上将应用程序作为可执行 jar 启动时,我的特殊字符被破坏了。
我错过了什么?
日食
Eclipse 的编码设置在 preferences->general->workspace
中,默认继承自 OS(windows 上的 cp1250)。
当您创建“运行 as”任务时,它也会存储它。因此,如果您更新 eclipse 的设置,请确保重新创建“运行 as”任务。您可以在启动应用程序时看到实际使用的值:Run configurations... -> Your Run task -> Common tab
.
您还可以通过在末尾添加 -Dfile.encoding=AnotherEncoding
来在 eclipse.ini 中强制编码。
命令行
从命令行启动时,它采用系统默认值,在 whidows 上为 cp1250。
您可以在程序的第一行打印编码,看看:System.out.println(System.getProperty("file.encoding"));
从命令行指定编码:java -Dfile.encoding=UTF-8 yourApp.jar
另见
也看看这个:
This indicates a problem with your code. Your code is currently
depending on the default platform encoding, and doesn't work if that
encoding is not "UTF-8". therefore, you should change the places in
your code which depend on the default platform encoding to use the
"UTF-8" encoding explicitly.
我的 Rest-Application 在 Eclipse 下 运行 时以正确的编码传送数据。但是当我在 Windows 系统上将应用程序作为可执行 jar 启动时,我的特殊字符被破坏了。
我错过了什么?
日食
Eclipse 的编码设置在 preferences->general->workspace
中,默认继承自 OS(windows 上的 cp1250)。
当您创建“运行 as”任务时,它也会存储它。因此,如果您更新 eclipse 的设置,请确保重新创建“运行 as”任务。您可以在启动应用程序时看到实际使用的值:Run configurations... -> Your Run task -> Common tab
.
您还可以通过在末尾添加 -Dfile.encoding=AnotherEncoding
来在 eclipse.ini 中强制编码。
命令行
从命令行启动时,它采用系统默认值,在 whidows 上为 cp1250。
您可以在程序的第一行打印编码,看看:System.out.println(System.getProperty("file.encoding"));
从命令行指定编码:java -Dfile.encoding=UTF-8 yourApp.jar
另见
也看看这个:
This indicates a problem with your code. Your code is currently depending on the default platform encoding, and doesn't work if that encoding is not "UTF-8". therefore, you should change the places in your code which depend on the default platform encoding to use the "UTF-8" encoding explicitly.