好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

intellij idea设置统一JavaDoc模板的方法详解

idea设置统一javadoc模板

 设置普通注释

按照如下导航找到位置:

?

1

setting > editor > file and code templates > includes > file header

复制如下,即可实现简单的javadoc注释

?

1

2

3

4

/**

  * @author : chenliwu

  * @date : ${date} ${time}

  */

自定义模板

 方法注释

按照如下导航找到位置:

?

1

setting > editor > live templates

看到右边的 + 按钮,选择第二项 2. template group… group 名字随便定义

增加好 group 之后,点击选中自己添加的 group,再点击右边的**+**选择第一项 1. live template

按照下图设置,

?

1

2

3

4

5

6

7

8

**

  * description: $description$

$params$

  * @return $ return $

  * @throws $ throws $

  * @author chenliwu

  * @date $date$ $time$

  */

其中params对应的是用脚本写的:

?

1

groovyscript( "def result=''; def stop=false; def params=\"${_1}\".replaceall('[\\\\[|\\\\]|\\\\s]', '').split(',').tolist(); if (params.size()==1 && (params[0]==null || params[0]=='null' || params[0]=='')) { stop=true; }; if(!stop) { for(i = 0; i < params.size(); i++) {result+=' * @param ' + params[i] + ' description' + ((i < params.size() - 1) ? '\\n' : '')}; }; return result;" , methodparameters())

类名注释

同理:

?

1

2

3

4

5

6

**

  * description: $description$

  * @author chenliwu

  * @version 1.0

  * @date $date$ $time$

  */

这样一来[/] + 你的快捷触发键 + 快捷生成按钮 即可一键生成你要的javadoc模板注释

到此这篇关于intellij idea设置统一javadoc模板的文章就介绍到这了,更多相关idea javadoc模板内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

原文链接:https://blog.csdn.net/Amir_wu/article/details/115384834

查看更多关于intellij idea设置统一JavaDoc模板的方法详解的详细内容...

  阅读:26次