IDEA console garbled ultimate solution

1. Problem Description

  Because IDEA 2019.1 of the machine there is a problem can not be connected to the plug-shops and Spring Boot template, you reinstall the latest version of IDEA 2019.2.4, use for some time, did not change any configuration console Chinese somehow the start garbled. Use a variety of ways online, still not been resolved.

 

2. Causes of the problem

  Having tried all the methods failed to solve, I saw someone said it might be because there are two IDEA environment configuration in the cache directory installation directory and projects, because if the project even if modify the cache configuration IDEA installation directory configuration is also to no avail, still can not change the cache directory configuration, it is still garbled.

  According to this idea, I began to test in the end which place there is a problem. First, because of the use Tomcat, so Tomcat may be used with IDEA GBK and UTF-8 lead to a distortion, and later added a program within the console output is garbled, it is determined that it should not be just a matter of Tomcat, and because use is Spring Boot, so not good built-in Tomcat configuration changes. After I was thinking that if I re-create a project will look garbled, then use the template to create a Spring Boot project, after testing found either to the console or in the Tomcat program, are not garbled, I have determined because the cache configuration as a result.

 

3. Solution

  Now that we know the cause of the problem, the solution will have to clear the cache on it.

  Tip: Before you operate the following operations, make sure the settings are correct IDEA, garbled or may still exist.

  In the IDEA project, click on the upper left corner of File-Invalidate Caches / Restart.

  

  Pop-up warning box, select Invalidate and Restart.

  

  After clicking the button, IDEA will automatically shut down and restart, if a lot before the project is large, then rebuild the cache speed will be relatively slow.

  Start the project, found that the console output either Tomcat or program output text is normal.

 

4. Other solutions

  The method is to provide the users, if it can not be resolved, either turn a blind eye, or reinstall the IDEA.

  (1) Local Tomcat issue

    If you are using the machine Tomcat, you need to modify Tomcat's server.xml file.

    Open the Tomcat installation directory, locate the server.xml file in the conf directory and open.

    Found protocol = "HTTP / 1.1" tag, add  the URIEncoding = "UTF-. 8"  , the following effects.

    

    Logging.properties find the file in the same directory, use a text editor to open.

    Find "java.util.logging.ConsoleHandler.encoding", fix the value to "UTF-8".

    To save and restart Tomcat.

    You can also set the IDEA, the replacement project but still need to configure, inconvenient.

    In the project home the top, find the "Run", select "Edit Configurations ...".

    Opening the left side of the "Templates", find the "Tomcat Server" - "Local".

    Enter "VM options" in  -Dfile.encoding = UTF-. 8  , select Apply to save, to restart Tomcat.

    

  (2) Spring built Tomcat issue

    Open the pom.xml of the project, add the plugin in the <build>, the project to restart.

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.1.7.RELEASE</version>
                <configuration>
                    <jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
                </configuration>
            </plugin>
        </plugins>
    </build>

  (3) IDEA配置问题

    打开IDEA安装目录下的bin文件夹,找到两个配置文件:idea.exe.vmoptions和idea64.exe.vmoptions。

    用文本编辑器打开这两个文件,分别在最后一行添加 -Dfile.encoding=UTF-8 。

    保存并重启IDEA即可。

    

  (4) IDEA字符集设置问题

    打开IDEA的Settings设置界面,找到 Editor-File Encodings。

    将三个下拉栏都设置为"UTF-8",保存并重启IDEA。

    

Guess you like

Origin www.cnblogs.com/NyanKoSenSei/p/12004845.html