一元扔、IDEA中設(shè)置類注釋模版的路徑
路徑:IntelliJ IDEA-->Preferences-->Editor-->File and Code Templates-->Files躯保, 參照如下圖:
??注意:生成的標(biāo)簽,如果提示wrong tag的警告澎语,可以選中一個(gè)標(biāo)簽途事,然后option+enter鍵 add tag to custorm tags --> Fix all 就OK了。
類配置內(nèi)容如下:
/**
*@ClassName ${NAME}
*@Description 請描述類的業(yè)務(wù)用途
*@Author ${USER}
*@Date ${DATE} ${TIME}
*@Version 1.0
**/
二擅羞、IDEA中設(shè)置方法注釋模版的路徑
路徑:IntelliJ IDEA-->Preferences-->Editor-->Live Templates尸变, 參照如下圖:
設(shè)置新的組名:userDefine
因?yàn)镮DEA生成注釋的默認(rèn)方式是:/*+模板名+快捷鍵(比如若設(shè)置模板名為add快捷鍵用Tab,則生成方式為
/*add+Tab)减俏,如果不采用這樣的生成方式IDEA中沒有內(nèi)容的方法將不可用召烂,例如獲取方法參數(shù)的methodParameters()、
獲取方法返回值的methodReturnType()
其中娃承,param的配置建議使用groovy腳本骑晶,如下:
groovyScript("if("
{_1}".replaceAll('[\\[|\\]|\\s]', '').split(',').toList();for(i = 0; i < params.size(); i++) {if(i<(params.size()-1)){result+=' * @param ' + params[i] + ' ' + params[i] + '\n'}else{result+=' * @param ' + params[i] + ' '+ params[i] }}; return result;}", methodParameters());
生成方法效果如下: