文章目录
问题现象
运行 tomcat 后,控制台输出乱码

解决排查过程
1. 检查 idea 编码设置
- 进入
File->Settings - 在设置窗口中,导航到
Editor->File Encodings。 - 确保
Global Encoding和Project Encoding都设置为UTF-8。
2. 检查 tomcat 配置
确保 tomcat 的配置中编码设置正确
-
打开 tomcat 的 Edit Configurations 页面
-
在配置项
VM options文本框中输入sh-Dfile.encoding=UTF-8

如果以上还不能解决问题,尝试以下两种方案
3.检查 idea 配置文件
- 打开 idea 的安装目录
- 打开 bin 文件下
idea64.exe.vmoptions配置文件 - 在尾部加 -Dfile.encoding=UTF-8
若 3 不行,尝试第四种解决方案
4.在 Help 菜单栏中,修改Custom VM Options
- 在该配置文件尾部增加 -Dfile.encoding=UTF-8
