Create annotations automatically when eclipse creates a new Java class

Source: Internet
Author: User

In order to form a personal Java code style, when we develop in the project team, we can make some formatting on our own code, as follows:

Method one: Settings in eclipse automatically generate comments when new classes are created

Windows–>preference
Java–>code Style–>code Templates
Code–>new Java Files
Edit it

${filecomment}${package_declaration}/*** @author 作者 E-mail:* @version 创建时间:${date} ${time}* 类说明*/${typecomment}${type_declaration}

Method Two:

Open the parameter Settings panel from the menu window->preference and select:
Java-code Style--code Templates

Select Comments on the right, place the files item, and then choose "Edit" on the right to enter edit mode:

After entering edit mode, you can customize the annotations. You can also insert some variables, such as year, date, and so on.

Finally, make sure that the Code-and New java files have: "${filecomment}"

Of course, with the "Export" and "import" functions, you can export your own templates for use on other machines.

The above is a file comment, and the method in the class automatically adds a comment similar to the types below files.

Eclipse shortcut key: Alt+shift+j after selecting your method

Create annotations automatically when eclipse creates a new Java class

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.