Eclipse automatically generates feature settings such as author, date comment, and more

Source: Internet
Author: User

When you write Java code using Eclipse, the automatically generated comment information is generated in a pre-set format.

Modify author, date comment format: Open windows->preferences->java->code style->code Templates, click Comments in the right window, you can see a lot of options, We can edit this comment information template.

If we want to set the author information and date information at the beginning of a Java file.

Select types, click Edit, and

/**

* @author ${user}

* ${tags}

*/

Delete the ${user}, change it to the name you want to display, delete ${tags}, click Insert Variable, select Date, and the date information will be generated automatically. When you need to add a comment, click Sources->ganarate Element Comment, or use the shortcut key Alt+shift+j, Eclipse automatically adds a comment before the class.

The specification for annotations is as follows:

File Comment Tags:

/**

* <p>title: ${file_name}</p>

* <p>description: </p>

* <p>copyright:copyright (c) 2007</p>

* <p>Company:LTGames</p>

* @author LINRZ

* @date ${date}

* @version 1.0

*/
Type Comment Label (note for Class):

/**

* <p>title: ${type_name}</p>

* <p>description: </p>

* <p>Company:LTGames</p>

* @author LINRZ

* @date ${date}

*/
Field Comment Label:

/** ${field}*/

Constructor Tags:

/**

* <p>title: </p>

* <p>description: </p>

* ${tags}

*/

Method Tags:

/**

* <p>title: ${enclosing_method}</p>

* <p>description: </p>

* ${tags}

*/

Override method Label:

/* (non-Javadoc)

* <p>title: ${enclosing_method}</p>

* <p>description: </p>

* ${tags}

* ${see_to_overridden}

*/

Represent method Tags:

/**

* ${tags}

* ${see_to_target}

*/

Getter Method Tags:

/**

* @return ${bare_field_name}

*/

Setter Method Tags:

/**

* @param ${param} to set the ${bare_field_name}

*/

Environment Description:
windowsxp SP3
Eclipse3.6 Helios Release

Part of the. java file
---------------------

Eclipse-->windows-->preferences-->java-->code Style-->code templates-->code-->new Java files--> click the [Edit] button

In the first line of the file, add the following:

Java code

${filecomment}

${package_declaration}

/**

* Creation time: ${date} ${time}

* Project name: ${project_name}

* @author Daniel

* @version 1.0

* @since JDK 1.6.0_21

* File name: ${file_name}

* Class Description:

*/

${typecomment}

${type_declaration}

${filecomment}

${package_declaration}

/**

* Creation time: ${date} ${time}

* Project name: ${project_name}

* @author Daniel

* @version 1.0

* @since JDK 1.6.0_21

* File name: ${file_name}

* Class Description:

*/

${typecomment}

${type_declaration}



Or

Java code

${filecomment}

${package_declaration}

/**

* Filename: ${file_name}

* Copyright:copyright (c) 2010

* company:com

* @version: 1.0

* @since: JDK 1.6.0_21

* Create at: ${date} ${time}

* Description:

*

* Modification History:

* Date Author Version Description

* -----------------------------------------------------------------

* ${date} Daniel 1.0 1.0 Version

*/

${typecomment}

${type_declaration}

${filecomment}

${package_declaration}

/**

* Filename: ${file_name}

* Copyright:copyright (c) 2010

* company:com

* @version: 1.0

* @since: JDK 1.6.0_21

* Create at: ${date} ${time}

* Description:

*

* Modification History:

* Date Author Version Description

* ------------------------------------------------------------------

* ${date} Daniel 1.0 1.0 Version

*/

${typecomment}

${type_declaration}



Ii.. jsp file section
---------------------

eclipse-->windows-->preferences-->web-->jsp files-->editer-->templates-->new JSP File--> Click the [Edit] button

In the first line of the file, add the following:

Java code

<%--

Creation time: ${date}${time}

Founder: Daniel

Related instructions:

Jdk1.6.0_21 tomcat6.0.29 servlet2.5

--%>

<%--

Creation time: ${date}${time}

Founder: Daniel

Related instructions:

Jdk1.6.0_21 tomcat6.0.29 servlet2.5

--%>

When you create a. java or. jsp file in this way, Eclipse automatically writes the comments for us. You can also export your own templates for easy use on other machines through the export and import functions.

Eclipse automatically generates feature settings such as author, date comment, and more

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.