本文介绍了idea添加java类注释模版的方法,分享给大家,具体如下:

idea版本:intellij idea 2017.2.5 x64

eclipse能在类上方输入/**,回车添加类注释模版,但idea没有默认添加这个功能,需要做一些设置。下面介绍三种方法实现:

创建类默认添加类注释

手动添加类注释

批量添加javadoc注释

一、设置新建类默认添加注释

依次点击setting|editor|file and code templates,添加如图配置

例子:

/**

*describe:

*

*@author xxx

*@date ${year}/${month}/${day}

*/

支持的变量在描述内,找到需要配置即可!

二、利用live template手动添加注释模版

依次点击setting|editor|live templates

1、点击+添加templates group,如my live templates

2、点击+添加live templates,修改abbreviation,再添加模版内容,模版变量以$var$格式定义,如

/**

*describe:

*

*@author xxx

*@date $date$

*/

3. 点击define定义模版作用范围,选择java

4. 点击edit variables定义变量,表达式解释见附件

5. 保存后,在类任意位置输入cc即可添加模版

三、批量添加注释

安装javadoc插件,alt+insert即可批量添加注释,包括所有类和方法,但是不能定制化,注释都是固定的。

附件

item

description

annotated("annotation qname")

creates a symbol of type with an annotation that resides at the specified location. for an example, see live templates in the iterations group.

arrayvariable()

suggests all array variables applicable in the current scope. for an example, see live templates in the iterations group.

anonymoussuper()

suggests a supertype for a kotlin object expression.

camelcase(string)

returns the string passed as a parameter, converted to camel case. for example, my-text-file/my text file/my_text_file will be converted to mytextfile.

capitalize(string)

capitalizes the first letter of the name passed as a parameter.

capitalizeandunderscore(scamelcasename)

capitalizes the all letters of a camelcase name passed as a parameter, and inserts an underscore between the parts. for example, if the string passed as a parameter is foobar, then the function returns foo_bar.

casttoleftsidetype()

casts the right-side expression to the left-side expression type. it is used in the iterations group to have a single template for generating both raw-type and generics collections.

classname(sclassname)

returns the name of the current class (the class where the template is expanded).

classnamecomplete()

this expression substitutes for the class name completion at the variable position.

clipboard()

returns the contents of the system clipboard.

snakecase(string)

returns camelcase string out of snake_case string. for example, if the string passed as a parameter is foo_bar, then the function returns foobar.

complete()

this expression substitutes for the code completion invocation at the variable position.

completesmart()

this expression substitutes for the smart type completion invocation at the variable position.

componenttypeof ()

returns component type of an array. for example, see the live templates in the iterations group in the other group.

currentpackage()

returns the current package name.

date(sdate)

returns the current system date in the specified format.

by default, the current date is returned in the default system format. however, if you specify date format in double quotes, the date will be presented in this format:

decapitalize(sname)

replaces the first letter of the name passed as a parameter with the corresponding lowercase letter.

descendantclassenum()

shows the children of the class entered as a string parameter.

enum(scompletionstring1,scompletionstring2,...)

list of comma-delimited strings suggested for completion at the template invocation.

escapestring(sescapestring)

escapes the specified string.

expectedtype()

returns the type which is expected as a result of the whole template. makes sense if the template is expanded in the right part of an assignment, after return, etc.

filename(sfilename)

returns file name with extension.

filenamewithoutextension()

returns file name without extension.

firstword(sfirstword)

returns the first word of the string passed as a parameter.

groovyscript("groovy code")

returns groovy script with the specified code.

you can use groovyscript macro with multiple arguments. the first argument is a script text that is executed or a path to the file that contains a script. the next arguments are bound to _1, _2, _3, ..._nvariables that are available inside your script.

also, _editor variable is available inside the script. this variable is bound to the current editor.

guesselementtype ()

makes a guess on the type of elements stored in a java.util.collection. to make a guess, intellij idea tries to find the places where the elements were added to or extracted from the container.

iterablecomponenttype()

returns the type of an iterable component, such as an array or a collection.

iterablevariable()

returns the name of a variable that can be iterated.

linenumber()

returns the current line number.

lowercaseanddash(string)

returns lower case separated by dashes, of the string passed as a parameter. for example, the string myexamplename is converted to my-example-name.

methodname()

returns the name of the embracing method (where the template is expanded).

methodparameters()

returns the list of parameters of the embracing method (where the template is expanded).

methodreturntype()

returns the type of the value returned by the current method (the method within which the template is expanded).

qualifiedclassname()

returns the fully qualified name of the current class (the class where the template is expanded).

clear the shorten fq names check box.

rightsidetype()

declares the left-side variable with a type of the right-side expression. it is used in theiterations group to have a single template for generating both raw-type and generics collections.

snakecase(scamelcasetext)

returns snake_case string out of camelcase string passed as a parameter.

spaceseparated(string)

returns string separated with spaces out of camelcase string passed as a parameter. for example, if the string passed as a parameter is foobar, then the function returns foo bar.

subtypes(stype)

returns the subtypes of the type passed as a parameter.

suggestindexname()

suggests the name of an index variable. returns i if there is no such variable in scope, otherwise returns j if there is no such variable in scope, etc.

suggestvariablename()

suggests the name for a variable based on the variable type and its initializer expression, according to your code style settings that refer to the variable naming rules.

for example, if it is a variable that holds an element within iteration, intellij idea makes a guess on the most reasonable names, also taking into account the name of the container being iterated.

suggestfirstvariablename(sfirstvariablename)

doesn't suggest true, false, this, super.

time(ssystemtime)

returns the current system time.

typeofvariable(var)

returns the type of the variable passed as a parameter.

underscorestocamelcase(scamelcasetext)

returns the string passed as a parameter with camelhump letters substituting for underscores. for example, if the string passed as a parameter is foo_bar, then the function returns foobar.

underscorestospaces(sparameterwithspaces)

returns the string passed as a parameter with spaces substituting for underscores.

user()

returns the name of the current user.

variableoftype()

suggests all variables that may be assigned to the type passed as a parameter, for example variableoftype("java.util.vector"). if you pass an empty string ("") as a parameter, suggests all variables regardless of their types.

jsarrayvariable

returns javascript array name.

jsclassname()

returns the name of the current javascript class.

jscomponenttype

returns the javascript component type.

jsmethodname()

returns the name of the current javascript method.

jsqualifiedclassname

returns the complete name of the current javascript class.

jssuggestindexname

returns a suggested name for an index.

jssuggestvariablename

returns a suggested name for a variable.

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持萬仟网。

希望与广大网友互动??

点此进行留言吧!

java类的注释模板_IDEA添加Java类注释模版的方法相关推荐

  1. java 类注释模板下载_[JAVA] IDEA注释模板

    一.文件注释 创建文件后, 编译器会在类名前面生成固定的注释, 来丰富代码的可读性, 在阿里巴巴Java开发手册里也明确写到所有的类都必须添加创建者和创建日期. /** * description: ...

  2. myeclipse java注释模板_Eclipse/MyEclipse Java注释模板设置详解 ---转载自百度空间

    设置注释模板的入口: Window->Preference->Java->Code Style->Code Template 然后展开Comments节点就是所有需设置注释的元 ...

  3. C++中模板类使用友元模板函数 和友员非模版函数!使用不当出现编译错误:无法解析的外部符号…

    在c++海大本科课程设计的最后章节(模板使用 )中涉及到了在Mat类模板中定义友元函数friend Mat<T> operator+(Mat<T> &m, T num) ...

  4. python类的编写模板_python开发笔记-类

    类的基本概念: 问题空间:问题空间是问题解决者对一个问题所达到的全部认识状态,它是由问题解决者利用问题所包含的信息和已贮存的信息主动的地构成的. 初始状态:一开始时的不完全的信息或令人不满意的状况: ...

  5. idea java 注释模板_idea java 注释模板配置

    在网上找了好久,好多的文章都有一个共同的病点就是"@param注释当有多个参数时候,全部放在了一行里面",非常不友好. 以下是我整理好的,完全按照eclipse的注释风格. !!! ...

  6. idea的java项目怎么连数据库_idea 使用Java连接SQL Server数据库教程

    一.工具 1.IntelliJ IDEA 2019.2.4 2.SQL Server数据库,我这里使用的是SQL Server2008 二.数据库用户配置 1.新建一个登录用户 登录数据库 进入如下界 ...

  7. java swing 设置背景_swing-窗体添加背景图片的2种方法

    在美化程序时,常常需要在窗体上添加背景图片.通过搜索和测试,发现了2种有效方式.下面分别介绍. 1.利用JLabel加载图片 利用JLabel自带的setIcon(Icon icon)加载icon,并 ...

  8. java使用正则表达为数字添加千位符的简单方法

    "260000008".replaceAll("(?<=\\d)(?=(?:\\d{3})+$)", ","); // => 2 ...

  9. idea模板注释快捷键_idea生成文档注释快捷键

    技术文档 主体内容:可以认为是页面最想表达的内容总和.对于内容详情页来说,主体内容指从标题开始至正文内容结束,翻页区域也被视为主体内容,文章后的评论.分享.推荐等不视为主体内容. 首屏:用户点击搜索结 ...

最新文章

  1. Mysql—(1)—
  2. java类中的代码块,Java开发避坑指南!
  3. asp.net中将Excel文件(.xls)绑定到DataGrid
  4. 听说你想去大厂看妹子,带你看看字节跳动技术中台后端面试长啥样?
  5. oracle vm virtualbox右ctrl切换显示模式
  6. 【数据结构与算法】之深入解析“逆波兰表达式求值”的求解思路与算法示例
  7. 数学--数论--费马小定理+求逆元
  8. 注册中心 Spring Cloud Eureka
  9. OD使用教程20 - 调试篇20
  10. 6 日期字符串转日期_日期居然用字符串保存?我笑了
  11. 深入浅出mysql_深入浅出mysql索引
  12. 手机版wps支持格式
  13. 中兴 F607 光猫超级管理用户查看
  14. 纵横iGoogle工具世界的程序发明王
  15. php强行横屏,强制横屏app
  16. 计算机制图孔中心线,NX制图(11):如何创建各种中心线?(一)
  17. 查看linux Mac地址
  18. html5 JavaScript 邮箱地址验证
  19. 哈希消息认证码HmacSHA256-javascript版
  20. 如何打造高效的团队(一) - 团队架构

热门文章

  1. 想转行学python过来人提醒大家几点
  2. 核方法---径向基函数网络
  3. 事件冒泡和阻止事件冒泡
  4. 图的遍历——DFS(邻接矩阵)
  5. java file 操作之创建、删除文件及文件夹
  6. framework7使用笔记
  7. Linux下使用ssh动态验证码登陆机器
  8. 【转】Hbuilder MUI 页面刷新及页面传值问题
  9. 通过Navicat for MySQL远程连接的时候报错mysql 1130的解决方法
  10. sed学习系列---第3/3部分