您的位置:首页 > 编程语言 > Java开发

Eclipse中起始注释和结尾注释的设置,创建注释模版

2017-04-07 12:06 447 查看
类的起始部分需要有起始注释,说明这个类的一些基本属性的注释,如工程名、所在的包、作者、创建日期和版权申明等。 类的结尾部分需要有结尾注释,用来记录类的修订历史,修改人、修改的描述,如果有人review代码,需要写明review的人。

类的总体结构如下:
/*******************************************************************************
* @project: alms
* @package: com.acconsys.alms.util
* @file: Test.java
* @author: yinww
* @created: 2013-2-22
* @purpose:
*
* @version: 1.0
*
* Revision History at the end of file.
*
* Copyright 2013 AcconSys All rights reserved.
******************************************************************************/

package com.acconsys.alms.util;

public class Test {

}

/*******************************************************************************
* <B>Revision History</B><BR>
* [type 'revision' and press Alt + / to insert revision block]<BR>
*
*
*
* Copyright 2013 AcconSys All rights reserved.
******************************************************************************/


这些内容通过配置eclipse的preferences模板来实现(Java/Code Style/Code Templates和Java/Editor/Templates) 如:Java/Code Style/Code Templates/Code/New Java Files
/*******************************************************************************
* @project: ${project_name}
* @package: ${package_name}
* @file: ${file_name}
* @author: ${user}
* @created: ${date}
* @purpose:
*
* @version: 1.0
*
* Revision History at the end of file.
*
* Copyright ${year} AcconSys All rights reserved.
******************************************************************************/

${filecomment}
${package_declaration}

${typecomment}
${type_declaration}

/*******************************************************************************
* <B>Revision History</B><BR>
* [type 'revision' and press Alt + / to insert revision block]<BR>
*
*
*
* Copyright ${year} AcconSys All rights reserved.
******************************************************************************/


Java/Editor/Templates新建revHis,context选Java,内容如下
/*******************************************************************************
* <B>Revision History</B><BR>
* [type 'revision' and press Alt + / to insert revision block]<BR>
* Add the latest revision history at top of revision history.<BR>
*
*
*
* Copyright ${year} AcconSys All rights reserved.
******************************************************************************/


Java/Editor/Templates新建revision,context选Javadoc,内容如下
[Revision on ${date} ${time} by ${word_selection}${user}${word_selection}]<BR>


这样每次对java类做修改时,在结尾注释(修订注释)的顶部输入revision,输快捷键Alt + /就能自动完成修订功能的固定格式,开发人员再对本次修改内容做具体的描述。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  设置注释