1、下载插件JavaDoc
2、找到项目下的 .idea目录,把如下3的代码覆盖到intellij-javadocs-4.0.1.xml。
3、配置内容
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaDocConfiguration">
<GENERAL>
<MODE>UPDATE</MODE>
<OVERRIDDEN_METHODS>false</OVERRIDDEN_METHODS>
<SPLITTED_CLASS_NAME>true</SPLITTED_CLASS_NAME>
<LEVELS>
<LEVEL>METHOD</LEVEL>
<LEVEL>TYPE</LEVEL>
<LEVEL>FIELD</LEVEL>
</LEVELS>
<VISIBILITIES>
<VISIBILITY>DEFAULT</VISIBILITY>
<VISIBILITY>PROTECTED</VISIBILITY>
<VISIBILITY>PUBLIC</VISIBILITY>
</VISIBILITIES>
</GENERAL>
<TEMPLATES>
<CLASSES>
<CLASS>
<KEY>^.*(public|protected|private)*.+interface\s+\w+.*</KEY>
<VALUE>/**\n
* 描述该接口实现的功能\n
<#if element.typeParameters?has_content></#if><#list element.typeParameters as typeParameter> * @param <${typeParameter.name}> 泛型参数\n
</#list> *\n
* @since v1.0\n
* @author wangtao\n
* @date ${.now?string["yyyyMMdd HH:mm:ss"]}\n
*/</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+enum\s+\w+.*</KEY>
<VALUE>/**\n
* 描述该枚举的用途\n
*\n
* @since v1.0\n
* @author wangtao\n
* @date ${.now?string["yyyyMMdd HH:mm:ss"]}\n
*/</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+class\s+\w+.*</KEY>
<VALUE>/**\n
* 描述该类实现的功能\n
<#if element.typeParameters?has_content></#if><#list element.typeParameters as typeParameter> * @param <${typeParameter.name}> 描述此泛型参数\n
</#list> *\n
* @since v1.0\n
* @author wangtao\n
* @date ${.now?string["yyyyMMdd HH:mm:ss"]}\n
*/</VALUE>
</CLASS>
<CLASS>
<KEY>.+</KEY>
<VALUE>/**\n
* 描述该类实现的功能
*\n
* @since v1.0\n
* @author wangtao\n
* @date ${.now?string["yyyyMMdd HH:mm:ss"]}\n
*/</VALUE>
</CLASS>
</CLASSES>
<CONSTRUCTORS>
<CONSTRUCTOR>
<KEY>.+</KEY>
<VALUE>/**\n
* 描述该构造方法实现的功能\n
<#if element.parameterList.parameters?has_content> *\n
</#if><#list element.parameterList.parameters as parameter> * @param ${parameter.name} 描述此参数\n
</#list><#if element.throwsList.referenceElements?has_content> *\n
</#if><#list element.throwsList.referenceElements as exception> * @throws ${exception.referenceName} 抛出异常原因\n
</#list> *\n
* @since v1.0\n
* @author wangtao\n
* @date ${.now?string["yyyyMMdd HH:mm:ss"]}\n
*/</VALUE>
</CONSTRUCTOR>
</CONSTRUCTORS>
<METHODS>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(\w(\s*<.+>)*)+\s+get\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* 获取 ${partName}.\n
<#if element.typeParameters?has_content> * \n
</#if><#list element.typeParameters as typeParameter> * @param <${typeParameter.name}> 描述此泛型参数\n
</#list><#if element.parameterList.parameters?has_content> *\n
</#if><#list element.parameterList.parameters as parameter> * @param ${parameter.name} 描述此参数\n
</#list><#if isNotVoid> *\n
* @return 返回 ${partName}\n
</#if><#if element.throwsList.referenceElements?has_content> *\n
</#if><#list element.throwsList.referenceElements as exception> * @throws ${exception.referenceName} 描述抛出异常原因\n
</#list> *\n
* @since v1.0\n
* @author wangtao\n
* @date ${.now?string["yyyyMMdd HH:mm:ss"]}\n
*/</VALUE>
</METHOD>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(void|\w(\s*<.+>)*)+\s+set\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* Sets ${partName}.\n
<#if element.typeParameters?has_content> * \n
</#if><#list element.typeParameters as typeParameter> * @param <${typeParameter.name}> the type parameter\n
</#list><#if element.parameterList.parameters?has_content> *\n
</#if><#list element.parameterList.parameters as parameter> * @param ${parameter.name} the ${paramNames[parameter.name]}\n
</#list><#if isNotVoid> *\n
* @return the ${partName}\n
</#if><#if element.throwsList.referenceElements?has_content> *\n
</#if><#list element.throwsList.referenceElements as exception> * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
</#list> */</VALUE>
</METHOD>
<METHOD>
<KEY>^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+</KEY>
<VALUE>/**\n
* 程序入口\n
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
* @param ${element.parameterList.parameters[0].name} 描述此命令行参数\n
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} 描述抛出异常原因\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>.+</KEY>
<VALUE>/**\n
* 描述此方法实现的功能\n
<#if element.typeParameters?has_content> *\n
</#if><#list element.typeParameters as typeParameter> * @param <${typeParameter.name}> 描述此泛型参数\n
</#list><#if element.parameterList.parameters?has_content> *\n
</#if><#list element.parameterList.parameters as parameter> * @param ${parameter.name} 描述此参数\n
</#list><#if isNotVoid> *\n
* @return 返回 ${return} 描述此返回参数\n
</#if><#if element.throwsList.referenceElements?has_content> *\n
</#if><#list element.throwsList.referenceElements as exception> * @throws ${exception.referenceName} 描述抛出异常原因\n
</#list> *\n
* @since v1.0\n
* @author wangtao\n
* @date ${.now?string["yyyyMMdd HH:mm:ss"]}\n
*/</VALUE>
</METHOD>
</METHODS>
<FIELDS>
<FIELD>
<KEY>^.*(public|protected|private)*.+static.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
* ${element.getName()} 描述此常量\n
*/</VALUE>
</FIELD>
<FIELD>
<KEY>^.*(public|protected|private)*.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
<#if element.parent.isInterface()> *${element.getName()} 描述此常量\n
<#else> *${element.getName()} 描述此字段\n
</#if> */</VALUE>
</FIELD>
<FIELD>
<KEY>.+</KEY>
<VALUE>/**\n
<#if element.parent.isEnum()> *${element.getName()} 描述此枚举常量\n
<#else> *${element.getName()} 描述此字段\n
</#if>*/</VALUE>
</FIELD>
</FIELDS>
</TEMPLATES>
</component>
</project>
请注意:把以上作者wangtao改为你的名字;
配置注释模板
1、路径 File->Settings-> Live Templates
*
date ->date()
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())
return->methodReturnType()
==》配置说明,必须一模一样,否则后果自负~
*
* 功能描述
* @author wangtao
* @date $date$
$params$
* @return $return$
*/
try
try {
} catch (Exception e) {
log.error("Exception.is", e);
}