IDEA巨详细配置(基本配置,模版配置,插件推荐)

323 阅读2分钟

IDEA配置清单

本文主要探讨主流开发工具Intellj IDEA的常用配置及部分插件,供读者参考。

常用配置

配置JDK

配置自动导包

配置Maven(内嵌)

配置阿里云镜像加速

Settings.xml

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
 
  <pluginGroups>
  </pluginGroups>

  <proxies>
  </proxies>

  <servers>
  </servers>

  <mirrors>  
    <mirror>  
      <id>alimaven</id>  
      <name>aliyun maven</name>  
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
      <mirrorOf>central</mirrorOf>          
    </mirror>
  </mirrors>

  <profiles>
  </profiles>

</settings>

字体修改

设置每次启动idea不自动打开项目

配置内存使用量显示

IDEA注释配置

三种常用的 Java 注释方式

    // 声明常量
    int number;
    /*
     * 类主函数
     */
    public static void main(String[] args) {
    }
    /**
     * @param masterId	品牌商Id
     * @param shopId	店铺Id
     * @param skuId		商品skuId
     * @description: 校验商品标识码与店铺的所属关系
     * @return: net.jdcloud.APIECRM.model.ValidateSkuUsingGETResponse
     * @author: niaonao
     * @date: 2020/01/13
     */
    public static ValidateSkuUsingGETResponse validateSkuUsing(String masterId, String shopId, String skuId){
        return null;
    }

自定义注释模板

类注释模板

配置模板

菜单路径 File-Settings-Editor-File and Code Templates-Incudes-File Header 下添加注释模板,配置模板后点击 Apply OK 应用。

自定义注释模板

/**
 * @className: ${NAME}
 * @description: TODO 类描述 
 * @author: niaonao
 * @date:  ${DATE}
 **/

新建接口文件自动生成注释,效果如下

/**
 * @className: CrowdService
 * @description: 人群对象业务
 * @author: niaonao
 * @date: 2020/1/13
 **/
public interface CrowdService {
}

自定义注释模板不完全变量参考表

预定义变量描述信息
${NAME}the name of the current file
${PACKAGE_NAME}name of the package in which the new file is created
${USER}current user system login name
${DATE}current system date
${TIME}current system time
${YEAR}current year
${MONTH}current month
${MONTH_NAME_SHORT}first 3 letters of the current month name. Example: Jan, Feb, etc.
${MONTH_NAME_FULL}full name of the current month. Example: January, February, etc.
${DAY}current day of the month
${DAY_NAME_SHORT}first 3 letters of the current day name. Example: Mon, Tue, etc.
${DAY_NAME_FULL}full name of the current day. Example: Monday, Tuesday, etc.
${HOUR}current hour
${MINUTE}current minute
${PROJECT_NAME}the name of the current project

方法注释模板

配置模板

菜单路径 **File-Settings-Editor-Live Templates**下添加一个新模板组,名字自定义 JavaTemplateGroup。选中模板组,右侧点击新增按钮,创建新模板。

  • Abbreviation 配置为*
  • Description 自定义描述信息。
  • Template Text 自定义模板
*
 $param$
 * @description: TODO
 * @return: $return$
 * @author: niaonao
 * @date: $date$
 */

Edit variables 编辑变量

  • 变量 return 表达式为 methodReturnType()
  • 变量 date 表达式为 date()
  • 变量 param 表达式为
groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {result+='* @param: ' + params[i] + ((i < params.size() - 1) ? '\\n ' : '')};return result", methodParameters()) 

若有警告信息No Applicable contexts,点击 Define 选中 Java 即可。

此处 Expend With 配置为 Enter 回车键,注释生成快捷方式,看个人习惯,也可以时 Tab 键。

点击 Apply OK 应用配置即可。效果如下

    /**
     * @param: masterId
     * @param: shopId
     * @param: skuId
     * @description: TODO
     * @return: net.jdcloud.APIECRM.model.ValidateSkuUsingGETResponse
     * @author: niaonao
     * @date: 2020/1/13
     */
    public static ValidateSkuUsingGETResponse validateSkuUsing(String masterId, String shopId, String skuId) {
        return null;
    }

IDEA插件目录

插件下载:IDEA的Marketplace或者从官网下载后导入plugins.jetbrains.com/

必须安装的插件

  1. Alibaba Java Coding Guidelines 阿里规约插件
  2. Lombok---代码简化工具

推荐安装的插件

  1. Jrebel---热部署插件
  2. Maven Helper---maven冲突管理插件
  3. Mybatis Log Plugin---sql日志自动组装插件
  4. MyBatisCodeHelper-Pro---代码生成器插件
  5. RESTfulToolkit---url快速定位方法插件
  6. Translation---翻译插件
  7. Rainbow Brackets---花括号
  8. Key Promoter X---快捷键学习工具