1.类注释

File -> Settings -> Editor -> File and Code Templates -> Includes -> FileHeader

 /**     
  * @describe: TODO 
  * @author: zhuCw
  * @date: ${DATE} ${TIME}
  */

IDEA 代码风格设置 随笔 第1张

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

2.缩进

采用4个空格缩进,或者设置tab键为4个空格, 不能勾选Use tab character,参考下图

File -> Setting -> Editor -> Code Style -> java -> Tabs and Indents

IDEA 代码风格设置 随笔 第2张

3.插件

3.1 google-java-format (格式化代码)

File -> Setting -> Marketplace -> 搜索google-java-format -> install -> Disable

3.2 save actions (保存格式化)
  • 安装 :File -> Setting -> Marketplace -> 搜索 save actions -> install -> Disable

  • 设置 File -> Setting -> Other Setting -> Save Actions

    • 保存自动格式化
    • 去掉多余imports
    • 保存时格式化整个文件

IDEA 代码风格设置 随笔 第3张

3.3 Alibaba Java Coding Guidelines plugin (阿里代码规范扫描)
  • 安装:File -> Setting -> Marketplace -> 搜索 Alibaba Java Coding Guidelines plugin -> install -> Disable

  • 扫描方法

    选中扫描的项目 -> 右键

    IDEA 代码风格设置 随笔 第4张

  • 扫描结果

    IDEA 代码风格设置 随笔 第5张

4.导入Setting

  • setting文件 在百度云盘
链接:https://pan.baidu.com/s/1azh6PAVWgiGWzpotaJV7eA 
提取码:dg48 

File -> Settings -> Code Style -> 设置图标 -> import Scheme

IDEA 代码风格设置 随笔 第6张

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄