目录
idea版本:
解决方法:
一、基本方法
1. File -> Settings -> Editor
2.
二、Maven乱码解决方法
三、运行时乱码解决方法
四、因为以前乱设置导致的乱码
idea版本:
![](https://img-blog.csdnimg.cn/56044d23919247878ee5585fc62db7b8.png)
解决方法:
一、基本方法
1. File -> Settings -> Editor
![](https://img-blog.csdnimg.cn/5301746916484664ba7a4bae457576ee.png)
1.1Editor -> General -> Console:将Default Encoding改为UTF-8
![](https://img-blog.csdnimg.cn/9c7b75ed986348108e0e062dafac2dd6.png)
1.2 Editor -> File Encodings:将Global Encoding、Project Encoding、Default encoding for properties files改为UTF-8
![](https://img-blog.csdnimg.cn/a39cc445fc664583864b02f7a63aca93.png)
2.
打开idea安装所在路径,进入bin文件,找到idea64.exe.vmoptions或者idea.exe.vmoptions,在其中添加一行-Dfile.encoding=UTF-8
![](https://img-blog.csdnimg.cn/64d83b6d8c38449c828e2180eb5b86e8.png)
![](https://img-blog.csdnimg.cn/2e669811f2714c0887b28b22e57f5eff.png)
二、Maven乱码解决方法
File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Runner:在VM Options填上-Dfile.encoding=GB2312![](https://img-blog.csdnimg.cn/611634ad9435441a900dd2ac24a17078.png)
三、运行时乱码解决方法
点击Edit Configurations...进入Run/Debug Configurations中,在当前运行的控制台中的VM options中填上-Dfile.encoding=UTF-8
![](https://img-blog.csdnimg.cn/79f00c6b08074d90bddb785bcddb4c1e.png)
![](https://img-blog.csdnimg.cn/06e2169f736f4655b882b4bd7aa3f527.png)
四、因为以前乱设置导致的乱码
如果以上还是不行,可能是以前在当前项目中设置过其它的编码格式,需要更改
1、在当前项目中找到.idea文件夹,找到encodings.xml,打开其所在位置
![](https://img-blog.csdnimg.cn/ad7f9075cdf840d6b15922fc8fc99717.png)
![](https://img-blog.csdnimg.cn/8d8b278bc190437a890ab1e493ef1b49.png)
![](https://img-blog.csdnimg.cn/73895e92d5674fce8d1617e128407fdb.png)
2、找到encodings.xml文件后打开编辑,将其中的不是UTF-8的格式都改为UTF-8