
从Eclipse切换到IntelliJ Idea有好多配置不太一样,在这里记录下常用的配置。
题图:from IntelliJ
Inspection 代码检查
在设置目录中,editor –> inspections用来配置各种代码检查以及警告。
- 开启import *提示
 editor –> inspections –> java –> imports
 勾选* import
- 工具类必须为final、不能含有public构造方法、必须有private构造方法
 editor –> inspections –> java –> class structure
 勾选utility class is not final
 勾选utility class with public constructor
 勾选utility class without private constructor
- equals()与hashCode()方法必须成对出现
 editor –> inspections –> java –> probable bugs
 勾选equals and hashcode() not paired
- 可序列化类没有声明serialVersionUID
 editor –> inspections –> java –> Serialization issue
 勾选Serializable class without 'serialVersionUID'
Code Style 代码风格
- else新起一行
 editor –> code style –> java –> if() statement
 勾选else on new lineforce brace选择always
- 方法参数过长自动换行
 editor –> code style –> java –> method declarationparameters选择wrap if long
- 禁用import *
 editor –> code style –> java –> importsclass count to use import with *填写500names count to use static import with *填写500
- 配置import顺序
 editor –> code style –> java –> imports –> import layout
 参考链接(stackoverflow.com)
IDE配置
- 自动import
 editor –> general –> auto import
 勾选optimize imports on the fly
 勾选add unambiguous imports on the fly
- 编辑器显示行号
 editor –> general –> apperance
 勾选show line numbers
- 自动补全main函数
 editor –> live templates –> other
 右侧点击加号,如下图配置  
- 去掉新文件自动添加的created by注释
 editor –> file and code templates
 找到需要修改的模板,按图中所示,将红框内内容替换为空行  
- 版本控制显示修改文件及目录
 version control
 勾选show directories with changed descendants