IDEA初始化配置

模板

先演示最终效果,从而决定这篇文章是不是你需要的.

package edu.common.log;

/**
 * 微信服务接口
 *
 * @author lyh
 * @date 2020/10/28 下午2:42
 */
public interface WxService {


  /**
   * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求.
   *
   * @param url 请求接口地址
   * @param jsonObject  请求对象
   * @throws WxErrorException 请求失败,详情参考错误日志
   * @return  字符串返回对象
   *
   * @author  lyh
   * @date    2020/10/28 下午5:56
   */
  String post(String url, JsonObject jsonObject) throws WxErrorException;
}

类模板

模板可以直接跳转到Q4,其余的都是一些琐碎的话语.
下面讲几个注意事项:
Q1: 在IDEA哪里修改类模板
路径File | Settings | Editor | File and Code Templates
在这里插入图片描述
Q2: 哪些文件需要修改
推荐:类-接口-枚举类-注释类

Q3: 类模板的格式有考究吗
参考了JDK中的String源码注释,进行了简化(小声bb,简化了很多很多)

Q4: 类模板格式(本篇的核心重点)

/**
 * TODO
 *
 * @author lyh
 * @date ${DATE} ${TIME}
 */

Q5: 上述$DATE$是从哪来的,我可以去哪进行个性化配置?
参考,IDEA配置描述,英语渣渣的我都觉得不是很难,就不翻译了

Along with static text, code and comments, you can also use predefined variables (listed below) that will then be expanded like macros into the corresponding values. It is also possible to specify an arbitrary number of custom variables in the format ${<VARIABLE_NAME>}. In this case, before the new file is created, you will be prompted with a dialog where you can define particular values for all custom variables. Using the #parse directive, you can include templates from the Includes tab, by specifying the full name of the desired template as a parameter in quotation marks. For example: #parse(“File Header.java”)
Predefined variables will take the following values:
${PACKAGE_NAME}
name of the package in which the new file is created
${NAME}
name of the new file specified by you in the New <TEMPLATE_NAME> dialog
${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}

Q6: 为什么不勾选reformat according to style?
还是个人喜好,在测试的时候,如果勾选,会自动规整.是个不错的功能,只不过个人不太喜欢规整之后的格式,没有了换行.

方法模板

图中分为了四个区域a\b\c\d,方法模板也就是围绕这几个区域展开.

Q1:修改路径
File | Settings | Editor | Live Templates

Q2: 修改步骤(核心重点)
在这里插入图片描述
修改之前需要有一个组的概念:定义的快捷键都会以组的形式归纳.
第一步:新建组(a区域,第二行group)
第二步:构建快捷键(a区域,第一行livetemplate)
第三步:快捷键名称(这里使用了zz),快捷键注释(description)
第四步:模板格式(一定要严格按照格式来,首部的/不是漏加,是不能加,否则参数param无法正常显示)

**
 * TODO
 *
$params$ 
 * @return  $return$
 *    
 * @author  lyh
 * @date    $date$ $time$ 
 */

第五步:change作用域(c区域)
第六步:给变量赋值含义(此处存在缺陷,对于throws无法获取异常,有知晓的兄弟还请在评论区指出,不胜感激!)

    groovyScript("if(\"${_1}\".length() == 2) {return '';} else {def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList();for(i = 0; i < params.size(); i++) {if(i<(params.size()-1)){result+=' * @param ' + params[i] + ' ' + '\\n'}else{result+=' * @param ' + params[i] + ' '}}; return result;}", methodParameters());

在这里插入图片描述

第七步:自定义是否格式化reformat(个人还是不喜欢格式化没有勾选,会吞并换行)
第八步:使用快捷键,注意上步快捷键定义的方式,我是zz,而模板未定义/所以使用需要以/zz使用.
第九步:over

下一篇:快捷键的使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值