idea版本:2020.3.x
一、添加类注释模板(新建类自动生成)
1、打开idea,依次如下选择
File–>settings–>Editor–>File and Code Templates–>Includes
2、注释如下
/**
* @description:
* @author: xx
* @date ${YEAR}-${MONTH}-${DAY}
* @modified By:
*/
3、效果图
二、添加方法注释模板
1、打开idea,依次如下选择
File–>Settings–>Editor–>Live Templates
2、新建组:MyGroup
3、新建方法注释模板
4、注释如下
*
* @description:
* @author: xx
* @date $date$
* @param $param$
* @return $returns$
* @throws $throws$
*/
注意模板开头为:* ,不为 /**
5、编辑variables
上图第9步:
5.1 输入param默认值
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==0){result+=params[i] + ' '}else{result+='\\n' + ' * @param ' + params[i] + ' '}}; return result;}", methodParameters());
5.2 说明
throws 暂时没有可自动获取值的方法,若有道友知道自动获取异常值的方法,欢迎评论区指教