idea设置java类上的注释模板
idea打开配置路径:File>Settings>File>Editor>File and Code Templates>Files
依次选中Class、Interface、Enum、AnnotationType
在右侧框中填上如下注释模板:
/**
*
* @author 刘江平
* @date ${DATE} ${TIME}
*/
看图说话

idea设置java方法的注释模板
idea打开配置路径:File>Settings>File>Editor>Live Templates
1.新建Template Group:JavaMethod (名称自定义)

2.在模板组JavaMethod下新建Live Template:

3.Abbreviation设置为 * ;
4.Template text填如下注释代码:
*
*
* @author 刘江平
* @date $date$ $time$ $param$ $return$
**/
5.点击Edit variables,$参数配置如下:
date:date()
time:time()
param:groovyScript("def result=''; def arg1=\"${_1}\"; if(arg1 && arg1!='null'){def params=arg1.replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {if(params[i]){result+='\\n * @param ' + params[i]}}}; return result", methodParameters())
return:groovyScript("def result=''; def returnType=\"${_1}\"; if('void'!=returnType && returnType!='null'){result+='\\n * @return ' + returnType}; return result", methodReturnType())
@throws 没法配置,没有对应的获取方法
6.点击模板框下方的Define,设置模板应用范围为java,勾选Java



7.设置使用注释模板的快捷方式
鼠标点击模板组JavaMethod,然后在最上方By default expand with处选择enter

8.在方法上通过输入/**,再回车就可以使用这个模板了

本文详细介绍如何在IDEA中配置Java类和方法的注释模板,包括设置作者、日期等信息,以及如何通过LiveTemplates自定义注释样式。
1026

被折叠的 条评论
为什么被折叠?



