1.类头接口头部注释
选择File–>Settings–>Editor–>File and Code Templates–>Includes–>File Header.
注释模板如下:
/**
* All rights Reserved, Designed By www.XXXX.com
* @projectName ${PROJECT_NAME}
* @title ${NAME}
* @package ${PACKAGE_NAME}
* @description ${TODO}
* @author 韩武洽
* @date ${DATE} ${TIME}
* @version V1.0.0
* @copyright ${YEAR} www.XXXXX.com
* 注意 本内容仅限于 XXXXX科技有限公司,禁止外泄以及用于其他的商业
*/
配置方法包括如下:
![类头接口头部注释 方法如下:](https://i-blog.csdnimg.cn/blog_migrate/979758689156cfe6a5ddc2f46209685b.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/fb8f9304d9c65492cca219da69138337.png)
2. 方法注释
IDEA还没有智能到自动为我们创建方法注释,这就是要我们手动为方法添加注释,使用Eclipse时我们生成注释的习惯是
/**+Enter,这里我们也按照这种习惯来设置IDEA的方法注释
*
* $methodName$
$params$
* @Description 方法描述,必填 <br/>
* @return $return$
* @throw $throw$
* @author 韩武洽
* @createTime $date$ $time$
* @Version V1.0.0
$updateLog$
*/
方法注释参数:
$return$: methodReturnType()
$params$: 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())
$date$: date()
$time$: time()
$methodName$: concat(qualifiedClassName(),".",methodName())
$updateLog$: groovyScript("def result = ' * @Copyright : www.XXXX.com Inc. All rights reserved.' + '\\n';result += ' * @UpateLog :'+'\\t\\t'+'Modifier'+'\\t\\t'+'ModifyTime'+'\\t\\t'+'Reason/Contents' + '\\n'; result += ' * ---------------------------------------------------------' + '\\n *'; return result;")
配置方法如下:
File-->Settings-->Editor-->Live Templates
![](https://i-blog.csdnimg.cn/blog_migrate/a06e4db2714b71f334f907c059083c2a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a2253aa47e3eea815f8e1225cc1806b3.png)
3. 修改注释模板(在原先没有修改注释title)和第一步配置使用
$updateLog$
*$modifyContent$
*$separator$
*
参数如下:
$updateLog$: groovyScript("def result = ''; result += ' @UpateLog :'+'\\t\\t'+ 'Modifier'+'\\t\\t'+' ModifyTime'+'\\t\\t'+' Reason/Contents' + '\\n'; result += '* ---------------------------------------------------------'; return result;")
*$modifyContent$ : groovyScript("def result = ''; result +=' \\t\\t韩武洽\\t\\t\\t'+\"${_1} \"+\"${_2} \"+'\\t\\t修改内容' ",date(),time())
*$separator$: groovyScript("def result=' ---------------------------------------------------------';return result")
演示如下:
* @UpateLog : Modifier ModifyTime Reason/Contents
* ---------------------------------------------------------
* 韩武洽 2017/12/20 16:10 修改内容
* ---------------------------------------------------------
*
*/
4. 生成修改信息(在已近有修改title下生成)和第一步配置使用
$modifyContent$
*$separator$
*
参数:
$modifyContent$ : groovyScript("def result = ''; result +=' \\t\\t韩武洽\\t\\t\\t'+\"${_1} \"+\"${_2} \"+'\\t\\t修改内容' ",date(),time())
$separator$: groovyScript("def result=' ---------------------------------------------------------';return result")
整体注释模板演示:
/**
* XXXX.sys.dao.site.SiteMasterDao.findCountrywide
* @param
* @Description 方法描述,必填 <br/>
* @return com.alibaba.fastjson.JSONObject
* @throw
* @author 韩武洽
* @createTime 2017/12/20 15:47
* @Version V1.0.0
* @Copyright www.xxxxxxx.com Inc. All rights reserved.
* @UpateLog Modifier ModifyTime Reason/Contents
* ---------------------------------------------------------
* 韩武洽 2017/12/20 16:10 添加***字段
* ---------------------------------------------------------
* 韩武洽 2017/12/20 16:15 修改方法,添加逻辑判断
* ---------------------------------------------------------
* 韩武洽 2017/12/20 16:16 修改**bug
* ---------------------------------------------------------
*
*/