Eclipse annotation template settings

Source: Internet
Author: User

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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.