IntelliJ IDEA 乱码解决方案 (项目代码、控制台等)
IntelliJ IDEA 乱码解决方案 (项目代码、控制台等)
最近IDE从eclipse改成IntelliJ IDEA 了,原因是公司大部分人都在用这个IDE,而且一直推荐用,所以尝尝鲜。换的第一天,就遇到了哪个IDE都会遇到的乱码问题,耗费了好多时间最终解决了,因此在这边记录一下解决方案,以供后面参考。
总共有下面几种乱码的解决方案:
- 工程乱码
- 执行main函数时,控制台乱码
- 运行tomcat时,控制台乱码
PS: 如果下面方案不生效时,打开IDEA安装目录找到 idea.exe.vmoptions(64位为idea64.exe.vmoptions)文件, 在文件末尾加上 -Dfile.encoding=UTF-8
可以先做这一步,加上这个基本上很多都不会乱码了
1.工程乱码
打开File-Setting, 找到File Encodings这个选项,把encoding设置成你工程的编码即可,一般是UTF-8,如下图(红框的地方),然后重新rebuild一下,基本就行了
2.执行main函数时,控制台乱码
同样是打开setting,找到 Build,Execution,Deployment > Compiler > Java Compiler, 设置 Additional command line parameters选项为 -encoding utf-8,然后rebuild下,重新运行
3.运行tomcat时,控制台乱码
1) 打开Run/Debug Configuration,选择你的tomcat
2) 然后在 Server > VM options 设置为 -Dfile.encoding=UTF-8 ,重启tomcat
好了,三种解决乱码的方案大概就是这样,有问题大家留言
</div>
<div class="postDesc">posted @ <span id="post-date">2015-11-26 18:18</span> <a href="http://www.cnblogs.com/vhua/">icodeit</a> 阅读(<span id="post_view_count">2964</span>) 评论(<span id="post_comment_count">1</span>) <a href="https://i.cnblogs.com/EditPosts.aspx?postid=4998564" rel="nofollow">编辑</a> <a href="#" onclick="AddToWz(4998564);return false;">收藏</a></div>
</div>
<script type="text/javascript">var allowComments=true,cb_blogId=208640,cb_entryId=4998564,cb_blogApp=currentBlogApp,cb_blogUserGuid='59af0290-be84-e411-b908-9dcfd8948a71',cb_entryCreatedDate='2015/11/26 18:18:00';loadViewCount(cb_entryId);</script>
评论列表
<div class="feedbackItem">
<div class="feedbackListSubtitle">
<div class="feedbackManage">
<span class="comment_actions"></span>
</div>
<a href="#3575424" class="layer">#1楼</a><a name="3575424" id="comment_anchor_3575424"></a><span id="comment-maxId" style="display:none;">3575424</span><span id="comment-maxDate" style="display:none;">2016/12/8 9:53:31</span> <span class="comment_date">2016-12-08 09:53</span> <a id="a_comment_author_3575424" href="http://www.cnblogs.com/kiwifly/" target="_blank">KIWI丶</a> <a href="http://msg.cnblogs.com/send/KIWI%E4%B8%B6" title="发送站内短消息" class="sendMsg2This"> </a>
</div>
<div class="feedbackCon">
<div id="comment_body_3575424" class="blog_comment_body">谢谢,第三种成功</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3575424,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3575424,'Bury',this)">反对(0)</a></div><span id="comment_3575424_avatar" style="display:none;">http://pic.cnblogs.com/face/746311/20150417204747.png</span>
</div>
</div>
<div id="comments_pager_bottom"></div></div><script type="text/javascript">var commentManager = new blogCommentManager();commentManager.renderComments(0);</script>
</div>
【福利】微软Azure给博客园的你专属双重好礼
【推荐】融云发布 App 社交化白皮书 IM 提升活跃超 8 倍
【推荐】BPM免费下载
· 紫辉创投郑刚:有朱啸虎的行业都要小心,会堆钱
· 张小龙的「不克制」
· Oculus收购眼球追踪技术初创公司The Eye Tribe
· Tim Cook:AirPods “大获成功”,正全速生产满足需求
· 三星S换机助手升级:支持Windows 10 Mobile数据迁移
» 更多新闻...
· 高质量的工程代码为什么难写
· 循序渐进地代码重构
· 技术的正宗与野路子
· 陈皓:什么是工程师文化?