When the idea to start the project through maven, the display database information at the front desk, no Chinese garbled, mybatis display database information in the console, Chinese garbled.
When the procedures used System.out.println output Chinese also garbled. When using the idea of starting classes before starting Javaweb project, this error not occurred.
This first thought is wrong coding problems, problems encountered in coding the most common one is the way to solve the Chinese garbled when connecting to the database, when using jdbc connection to the database after the database name to add? CharacterEncoding = UTF- 8
? such as: jdbc: mysql: // localhost: 3306 / sheep characterEncoding = utf-8; and found that this method is still following the situation garbled in the console.
The second method is the idea installation directory, or targeting idea64.exe.vmoptions (idea.exe.vmoptions), the final addition "-Dfile.encoding = UTF-8" code files into the directory bin, but still can not solve the problem of Chinese garbled use.
The third method is encoded in the idea in setting is set to UTF_8, as shown, but it is also not solve the problem.
Finally solved by way of the Chinese distortion problems, specific solution is as follows:
Setting-> maven-> Runner VMoptions: -Dfile.encoding = GB2312, as shown below:
The final results are shown below:
Start maven project in the idea:
1. Start the class started, as shown below:
2. Use the maven command to start, click edit configurations, as follows:
Solve: maven default environment for jdk, you can only change as follows: In IDEA, open the File | Settings | Build, Execution, Deployment | Build Tools | Maven | Runner Add -Dfile.encoding = GBK in the VM Options, remember certain is GBK. That the use of words UTF-8, is still garbled, this is because the default platform encoding Maven is GBK, if you enter mvn -version at the command line, it will get the following information can be seen according Default locale! [Insert here picture description] (https://img-blog.csdnimg.cn/20200208094129972.png)
When the idea to start the project through maven, the display database information at the front desk, no Chinese garbled, mybatis display database information in the console, Chinese garbled.
When the procedures used System.out.println output Chinese also garbled. When using the idea of starting classes before starting Javaweb project, this error not occurred.
This first thought is wrong coding problems, problems encountered in coding the most common one is the way to solve the Chinese garbled when connecting to the database, when using jdbc connection to the database after the database name to add? CharacterEncoding = UTF- 8
? such as: jdbc: mysql: // localhost: 3306 / sheep characterEncoding = utf-8; and found that this method is still following the situation garbled in the console.
The second method is the idea installation directory, or targeting idea64.exe.vmoptions (idea.exe.vmoptions), the final addition "-Dfile.encoding = UTF-8" code files into the directory bin, but still can not solve the problem of Chinese garbled use.