解决IntelliJ IDEA 控制台中文乱码问题

如果log4j设置输出编码是utf-8,但是打印到控制台的是中文乱码,可以尝试第一个解决方法。 看了很多网上的,终于解决了。汇总

如图:                             

如果其中一种更改不行,可以尝试多种更改。

1:打开intelliidea安装路径,IntelliJIDEA15.0.6\bin找到idea.exe.vmoption文件,打开,在最后一行填加:“-Dfile.encoding=utf-8”,如图所示,保存。

2:设置idea file编码。在菜单栏找到”File->settings->搜索File Encodeing” 设置utf-8。如图所示

3:设置idea server编码。在菜单栏找到”run->editconfigration” 找到”server”选项卡 设置 vm option为 -Dfile.encoding=utf-8,如图3所示 (本人亲测非常有效)

成功:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

新增解决办法4  来源与评论区网友们 性感上单赵四、人工智能时代的小草、Mr.dadong 

HELP->Edit Custom VM OPtions中加 -Dfile.encoding=utf-8       重启idea
  
  
                        <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#csdnc-thumbsup"></use>
                        </svg><span class="name">点赞</span>
                        <span class="count">22</span>
                        </a></li>
                        <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-Collection-G"></use>
                        </svg><span class="name">收藏</span></a></li>
                        <li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-fenxiang"></use>
                        </svg>分享</a></li>
                        <!--打赏开始-->
                                                <!--打赏结束-->
                                                <li class="tool-item tool-more">
                            <a>
                            <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                            </a>
                            <ul class="more-box">
                                <li class="item"><a class="article-report">文章举报</a></li>
                            </ul>
                        </li>
                                            </ul>
                </div>
                            </div>
            <div class="person-messagebox">
                <div class="left-message"><a href="https://blog.csdn.net/qq_39136928">
                    <img src="https://profile.csdnimg.cn/9/9/1/3_qq_39136928" class="avatar_pic" username="qq_39136928">
                                            <img src="https://g.csdnimg.cn/static/user-reg-year/2x/3.png" class="user-years">
                                    </a></div>
                <div class="middle-message">
                                        <div class="title"><span class="tit"><a href="https://blog.csdn.net/qq_39136928" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">潘丶</a></span>
                                            </div>
                    <div class="text"><span>发布了93 篇原创文章</span> · <span>获赞 71</span> · <span>访问量 15万+</span></div>
                </div>
                                <div class="right-message">
                                            <a href="https://im.csdn.net/im/main.html?userName=qq_39136928" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
                        </a>
                                                            <a class="btn btn-sm  bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">关注</a>
                                    </div>
                            </div>
                    </div>
    
发布了45 篇原创文章 · 获赞 0 · 访问量 3541

如果log4j设置输出编码是utf-8,但是打印到控制台的是中文乱码,可以尝试第一个解决方法。 看了很多网上的,终于解决了。汇总

猜你喜欢

转载自blog.csdn.net/qq_44813090/article/details/104202473