大家在使用 Intellij IDEA 的时候会经常遇到各种乱码问题,甚是烦扰。

栈长也偶尔会用下IDEA,也有一些解决乱码的经验,我给大家总结了以下几类乱码的场景,绝壁能帮你解决 IDEA 各种乱码问题。

常见乱码场景及解决方案

1、项目源代码中文乱码

Settings > Editor > File Encodings > Global Encodings & Project Encodings 设置为:UTF-8

上面红色区域都统一设置一下。

2、Main方法运行,控制台中文乱码

Settings > Build, Execution, Deployment > Compile > Java Compiler > Additional command line parameters > 设置为:-encoding utf-8

3、Tomcat运行,控制台中文乱码

Edit Configurations > Tomcat Server > server > VM options > 设置为:-Dfile.encoding=UTF-8

idea > bin > idea.exe.vmoptions 或者 idea64.exe.vmoptions 配置文件末尾添加:-Dfile.encoding=UTF-8

如果还乱码,继续往下设置。

idea > Help 菜单 > Edit Custom VM Options…菜单,编辑配置文件,在末尾添加:-Dfile.encoding=UTF-8


好了,今天的表演就到这了,倍儿爽,建议收藏+转发,日后绝对有用~

  • Intellij IDEA 最常用配置详细图解
  • Intellij IDEA 非常6的10个姿势
  • Intellij IDEA 所有乱码解决方案
  • Intellij IDEA 阅读源码的4个绝技
  • Intellij IDEA Debug调试技巧