Portal for setting the annotation template:
Window-<preference-<Java-<codestyle-<code template, and then expand the comments node to be all elements that need to be annotated. We will introduce each element one by one:
File (Files) annotation label:
/**
* Copyright $ {year} company name. All rights reserved.
*
*@ Title:$ {File_name}
*@ Prject:$ {Project_name}
*@ Package:$ {Package_name}
*@ Description:$ {Todo}
*@ Author:$ {User}
*@ Date:$ {Date }$ {time}
*@ Version: V1.0
*/
Type (types) annotation label (class annotation ):
/**
*@ Classname:$ {Type_name}
*@ Description:$ {Todo}
*@ Author:$ {User}
*@ Date:$ {Date }$ {time}
* $ {Tags}
*/
Field (fields) annotation label:
/**
*@ Fieldname:$ {Field}
*@ Fieldtype:$ {Field_type}
*@ Description:$ {Todo}
*/
Constructor Tag:
/**
*@ Title:$ {Enclosing_type}
*@ Description:$ {Todo}
* $ {Tags}
*/
Method (constructor & Methods) label:
/**
*@ Title:$ {Enclosing_method}
*@ Description:$ {Todo}
* $ {Tags}
*@ Return:$ {Return_type}
*/
Overriding Methods labels:
/* (Non javadoc)
* @ Title: $ {enclosing_method}
* @ Description: $ {todo}
* $ {Tags}
* $ {See_to_overridden}
*/
Method label:
/**
* $ {Tags}
* $ {See_to_target}
*/
Getter method label:
/**
*@ ReturnThe $ {bare_field_name}
*/
Setter method label:
/**
*@ Param$ {Param} the $ {bare_field_name} to set
*/
You can also download and import the configured. xml file from the Internet. Click "I" for download!
PS: After setting according to the above method, you must go to Windows> preferences> General> content types, right-side context types tree, Open Text, select Java source file, enter the UTF-8 in the following default encoding input box, click Update, then set the Java file encoding to the UTF-8, otherwise there will be a problem with character encoding.
After the preceding settings, you can use the shortcut key Alt + Shift + J to quickly generate a document comment. The usage is as follows:
File Header comment: the file generated using the new-> class method will prompt whether to generate a comment in the option of the create class dialog box, which is selected by default. The generated. Java file contains the copyright information set above in the file header. If a Java file is created using the new-> file method, the copyright information of the file header is not automatically generated and must be entered manually. Method, class, field, and other annotations: you only need to select the method name, class name, or field name, and then use Alt + Shift + J to automatically generate comments, complete the information.