There are a total of 3 methods in this article, and the situation is to output Chinese garbled characters
Problem Description
Unable to output Chinese characters correctly: (Please correctly identify which kind of garbled characters you have!)
Solution
1. Easiest to think of
Under File -> Settings -> File Encodings, set the encoding format to UTF-8, which is the most common. Generally, when the idea is just installed or the project is just imported, the encoding format here has not been modified.
Modify it in one go!
2. If not, it is normal, see here
Modify the idea.exe.vmoption file
Open the bin directory of the idea installation path and find two files, idea.exe.vmoptions and idea64.exe.vmoptions
If you downloaded the 64-bit version, there is only one vmoptions file, which is normal , just modify one line and
add a line at the end of the text.
After saving, you need to restart idea.
Note: It is invalid to modify only in the help->Edit Custom VM Options of the idea
3. If it still doesn’t work, check it out
Go to the project startup configuration to check whether the encoding format of the container is set
Run->Edit Configration
Whether you run the main method directly, the startup method of the SpringBoot project, or tomcat, there is a configuration for
VM options, and this configuration is actively configured as -Dfile.encoding=utf-8, configure and restart the project.
4. If it doesn't work, you may have encountered the same problem as me
I originally downloaded the latest version of JDK, which is the version numbered 18. However, it is said that its built-in is GBK encoding, but my IDEA analysis is UTF-8. The two conflict, so the output is garbled.
Now, it is necessary to completely delete the original version of the JDK and re-download the JDK version 17.
Since both are available, it is really not random to choose which one to choose, depending on which one you need.
Then, just configure JDK in IDEA! ! ! (Environment variables and font size modification will not be mentioned)
At this time, the problem is finally solved.
This problem of garbled characters has really troubled me for a long time. It is strange that none of the methods found on the Internet are applicable. In the end, it is still a question of the version, and I have learned a lot.