设置注释模板的入口: Window->Preference->Java->Code Style->Code Template 然后展开Comments节点就是所有需设置注释的元素啦。现就每一个元素逐一介绍:

文件(Files)注释标签:

/**   
* @Title: ${file_name}  
* @Package ${package_name}  
* @Description: ${todo}(用一句话描述该文件做什么)  
* @author A18ccms A18ccms_gmail_com   
* @date ${date} ${time}  
* @version V1.0   
*/

类型(Types)注释标签(类的注释):

/**  
* @ClassName: ${type_name}  
* @Description: ${todo}(这里用一句话描述这个类的作用)  
* @author A18ccms a18ccms_gmail_com  
* @date ${date} ${time}  
*  
* ${tags}  
*/

字段(Fields)注释标签:

/**  
* @Fields ${field} : ${todo}(用一句话描述这个变量表示什么)  
*/  
构造函数标签:

/**  
* <p>Title: </p>  
* <p>Description: </p>  
* ${tags}  
*/

方法(Constructor & Methods)标签:

/**  
* @Title: ${enclosing_method}  
* @Description: ${todo}(这里用一句话描述这个方法的作用)  
* @param ${tags}    设定文件  
* @return ${return_type}    返回类型  
* @throws  
*/

覆盖方法(Overriding Methods)标签:

/* (非 Javadoc)  
* <p>Title: ${enclosing_method}</p>  
* <p>Description: </p>  
* ${tags}  
* ${see_to_overridden}  
*/

代表方法(Delegate Methods)标签:

/**  
* ${tags}  
* ${see_to_target}  
*/  
getter方法标签:

/**  
* @return ${bare_field_name}  
*/

setter方法标签:

/**  
* @param ${param} 要设置的 ${bare_field_name}  
*/

简单模板例子:  
<?xml version="1.0" encoding="UTF-8"?><templates><template autoinsert="true" context="fieldcomment_context" deleted="false" description="字段的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/**  
* @Fields ${field} : ${todo}(用一句话描述这个变量表示什么)  
*/  
</template><template autoinsert="true" context="gettercomment_context" deleted="false" description="getter 方法的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/**  
* @return ${bare_field_name}  
*/  
</template><template autoinsert="true" context="constructorcomment_context" deleted="false" description="创建的构造函数的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/**  
* <p>Title:${file_name} </p>  
* <p>Description: 构造函数</p>  
* ${tags}  
*/  
</template><template autoinsert="true" context="filecomment_context" deleted="false" description="已创建的 Java 文件的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/**    
* @Title: ${file_name}  
* @Package ${package_name}  
* @Description: ${todo}(用一句话描述该文件做什么)  
* @author DAIGUANGJIU     
* @date ${date} ${time}  
* @version V1.0    
*/  
</template><template autoinsert="true" context="settercomment_context" deleted="false" description="setter 方法的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">/**  
* @param ${param} 要设置的 ${bare_field_name}  
*/</template><template autoinsert="true" context="typecomment_context" deleted="false" description="创建的类型的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/**  
* @author ${user}  
*  
* ${tags}  
*/</template><template autoinsert="true" context="delegatecomment_context" deleted="false" description="代表方法的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/**  
* ${tags}  
* ${see_to_target}  
*/</template><template autoinsert="true" context="overridecomment_context" deleted="false" description="覆盖方法的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/** (非 Javadoc)  
* <p>Title: ${enclosing_method}</p>  
* <p>Description: </p>  
* ${tags}  
* ${see_to_overridden}  
*/</template><template autoinsert="true" context="methodcomment_context" deleted="false" description="非覆盖方法的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/**  
* ${tags}  
*/</template></templa  
<?xml version="1.0" encoding="UTF-8"?><templates><template autoinsert="true" context="fieldcomment_context" deleted="false" description="字段的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/**  
* @Fields ${field} : ${todo}(用一句话描述这个变量表示什么)  
*/  
</template><template autoinsert="true" context="gettercomment_context" deleted="false" description="getter 方法的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/**  
* @return ${bare_field_name}  
*/  
</template><template autoinsert="true" context="constructorcomment_context" deleted="false" description="创建的构造函数的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/**  
* <p>Title:${file_name} </p>  
* <p>Description: 构造函数</p>  
* ${tags}  
*/  
</template><template autoinsert="true" context="filecomment_context" deleted="false" description="已创建的 Java 文件的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/**  
* @Title: ${file_name}  
* @Package ${package_name}  
* @Description: ${todo}(用一句话描述该文件做什么)  
* @author DAIGUANGJIU   
* @date ${date} ${time}  
* @version V1.0  
*/  
</template><template autoinsert="true" context="settercomment_context" deleted="false" description="setter 方法的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">/**  
* @param ${param} 要设置的 ${bare_field_name}  
*/</template><template autoinsert="true" context="typecomment_context" deleted="false" description="创建的类型的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/**  
* @author ${user}  
*  
* ${tags}  
*/</template><template autoinsert="true" context="delegatecomment_context" deleted="false" description="代表方法的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/**  
* ${tags}  
* ${see_to_target}  
*/</template><template autoinsert="true" context="overridecomment_context" deleted="false" description="覆盖方法的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/** (非 Javadoc)  
* <p>Title: ${enclosing_method}</p>  
* <p>Description: </p>  
* ${tags}  
* ${see_to_overridden}  
*/</template><template autoinsert="true" context="methodcomment_context" deleted="false" description="非覆盖方法的注释" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/**  
* ${tags}  
*/</template></templa

例子2:  
<?xml version="1.0" encoding="UTF-8"?>  
<templates>  
    <template    
                autoinsert="false"    
                context="constructorcomment_context"    
                deleted="false"    
                description="Comment for created constructors"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment"  
                name="constructorcomment">  
    /**   
     * 创建一个新的实例 ${enclosing_type}.   
     *   
     * ${tags}   
     */   
    </template>  
    <template    
                autoinsert="true"    
                context="settercomment_context"  
                deleted="false"    
                description="Comment for setter method"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.settercomment"    
                name="settercomment">  
    /**   
     * @param ${param} the ${bare_field_name} to set   
     */   
    </template>  
    <template  
                autoinsert="false"    
                context="methodcomment_context"    
                deleted="false"    
                description="Comment for non-overriding methods"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.methodcomment"    
                name="methodcomment">  
    /**   
     * 此方法描述的是:   
     * @author: wangxiongdx@163.com   
     * @version: ${date} ${time}   
     */   
    </template>  
    <template    
                autoinsert="true"    
                context="delegatecomment_context"    
                deleted="false"    
                description="Comment for delegate methods"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"    
                name="delegatecomment">  
    /**   
     * ${tags}   
     * ${see_to_target}   
     */   
    </template>  
    <template  
                autoinsert="false"    
                context="filecomment_context"    
                deleted="false"    
                description="Comment for created Java files"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.filecomment"    
                name="filecomment">  
    /**   
     * 文件名:${file_name}   
     *   
     * 版本信息:   
     * 日期:${date}   
     * Copyright 足下 Corporation ${year}    
     * 版权所有   
     *   
     */   
    </template>  
    <template    
                autoinsert="false"    
                context="gettercomment_context"    
                deleted="false"    
                description="Comment for getter method"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.gettercomment"    
                name="gettercomment">  
    /**   
     * ${bare_field_name}   
     *   
     * @return  the ${bare_field_name}   
     * @since   CodingExample Ver(编码范例查看) 1.0   
    */   
    </template>  
    <template    
                autoinsert="true"    
                context="overridecomment_context"    
                deleted="false"    
                description="Comment for overriding methods"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.overridecomment"    
                name="overridecomment">  
    /* (non-Javadoc)   
     * ${see_to_overridden}   
     */   
    </template>  
    <template    
                autoinsert="false"    
                context="fieldcomment_context"    
                deleted="false"    
                description="Comment for fields"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment"    
                name="fieldcomment">  
    /**   
     * ${field}:${todo}(用一句话描述这个变量表示什么)   
     *   
     * @since Ver 1.1   
     */   
    </template>  
    <template    
                autoinsert="false"    
                context="typecomment_context"    
                deleted="false"    
                description="Comment for created types"    
                enabled="true"    
                id="org.eclipse.jdt.ui.text.codetemplates.typecomment"    
                name="typecomment">  
    /**   
     * 此类描述的是:   
     * @author: wangxiongdx@163.com   
     * @version: ${date} ${time}    
     */   
    </template>  
</templates>  
<?xml version="1.0" encoding="UTF-8"?>  
<templates>  
    <template  
                autoinsert="false"  
                  context="constructorcomment_context"  
                deleted="false"  
                description="Comment for created constructors"  
                enabled="true"  
                id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment"  
                name="constructorcomment">  
    /**  
     * 创建一个新的实例 ${enclosing_type}.  
     *  
     * ${tags}  
     */  
    </template>  
    <template  
                autoinsert="true"  
                context="settercomment_context"  
                deleted="false"  
                description="Comment for setter method"  
                enabled="true"  
                id="org.eclipse.jdt.ui.text.codetemplates.settercomment"  
                name="settercomment">  
    /**  
     * @param ${param} the ${bare_field_name} to set  
     */  
    </template>  
    <template  
                autoinsert="false"  
                context="methodcomment_context"  
                deleted="false"  
                description="Comment for non-overriding methods"  
                enabled="true"  
                id="org.eclipse.jdt.ui.text.codetemplates.methodcomment"  
                name="methodcomment">  
    /**  
     * 此方法描述的是:  
     * @author: wangxiongdx@163.com  
     * @version: ${date} ${time}  
     */  
    </template>  
    <template  
                autoinsert="true"  
                context="delegatecomment_context"  
                deleted="false"  
                description="Comment for delegate methods"  
                enabled="true"  
                id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"  
                name="delegatecomment">  
    /**  
     * ${tags}  
     * ${see_to_target}  
     */  
    </template>  
    <template  
                autoinsert="false"  
                context="filecomment_context"  
                deleted="false"  
                description="Comment for created Java files"  
                enabled="true"  
                id="org.eclipse.jdt.ui.text.codetemplates.filecomment"  
                name="filecomment">  
    /**  
     * 文件名:${file_name}  
     *  
     * 版本信息:  
     * 日期:${date}  
     * Copyright 足下 Corporation ${year}  
     * 版权所有  
     *  
     */  
    </template>  
    <template  
                autoinsert="false"  
                context="gettercomment_context"  
                deleted="false"  
                description="Comment for getter method"  
                enabled="true"  
                id="org.eclipse.jdt.ui.text.codetemplates.gettercomment"  
                name="gettercomment">  
    /**  
     * ${bare_field_name}  
     *  
     * @return  the ${bare_field_name}  
     * @since   CodingExample Ver(编码范例查看) 1.0  
    */  
    </template>

<template  
                autoinsert="true"  
                context="overridecomment_context"  
                deleted="false"  
                description="Comment for overriding methods"  
                enabled="true"  
                id="org.eclipse.jdt.ui.text.codetemplates.overridecomment"  
                name="overridecomment">  
    /* (non-Javadoc)  
     * ${see_to_overridden}  
     */  
    </template>  
    <template  
                autoinsert="false"  
                context="fieldcomment_context"  
                deleted="false"  
                description="Comment for fields"  
                enabled="true"  
                id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment"  
                name="fieldcomment">  
    /**  
     * ${field}:${todo}(用一句话描述这个变量表示什么)  
     *  
     * @since Ver 1.1  
     */  
    </template>  
    <template  
                autoinsert="false"  
                context="typecomment_context"  
                deleted="false"  
                description="Comment for created types"  
                enabled="true"  
                id="org.eclipse.jdt.ui.text.codetemplates.typecomment"  
                name="typecomment">  
    /**  
     * 此类描述的是:  
     * @author: wangxiongdx@163.com  
     * @version: ${date} ${time}  
     */  
    </template>  
</templates>

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ahhsxy/archive/2009/09/11/4542682.aspx

 
 

eclipse代码注释模版的更多相关文章

  1. Eclipse ADT 代码注释模版

    具体怎么用: 将下面的内容拷贝出来保存为XML文件,进入,Eclipse :Window --> Java --> Code Style --> Code Templates-> ...

  2. eclipse代码注释的设置

    http://blog.csdn.net/shiyuezhong/article/details/8450578 1. eclipse用户名的设置: 在eclipse的安装路径下,打开eclipse. ...

  3. Eclipse代码注释模板

    <?xml version="1.0" encoding="UTF-8"?><templates><template autoin ...

  4. Eclipse代码注释模板-code template

    参考帖子blog.csdn.net/security08/article/details/5588013 操作步骤:打开Window->Preferences->Java->Code ...

  5. Eclipse代码注释模板修改

    /** * @ClassName: ${type_name} * @author: <font color="red"><b>ZF</b>< ...

  6. 阿里p3c(代码规范,eclipse插件、模版,idea插件)

    阿里p3c 一.说明 代码规范检查插件p3c,是根据<阿里巴巴Java开发手册>转化而成的自动化插件. (高级黑:P-3C“Orion”,反潜巡逻机,阿里大概取p3c先进,监测,发现潜在问 ...

  7. eclipse中注释的代码依然会执行的解决方法

    问题: eclipse中注释的代码在debug的时候居然还能执行.那一刻内心是崩溃的.. 解决方案: 项目重编译显示都正常,并没有报错,然后发现项目编译后,WEB-INF/lib/classes中的c ...

  8. eclipse中添加Java代码注释模板

    eclipse中添加Java代码注释模板 1.Window->Preference->Java->Code Style->Code Template,进入注释编辑界面 2.文件 ...

  9. Eclipse中代码自动添加注释及代码注释模板

    介绍 为了提高代码的可读性以及为了有些代码有洁癖的人的需求,我们要从学生到职业进行迈进的过程中,必须把以前的那种代码可读性不高的习惯改掉,因为我们必须要与企业接轨.. 好了,废话不多说,反正就是提升自 ...

随机推荐

  1. HDU——2064汉诺塔III

    汉诺塔III Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  2. co模块总结

    1.thunk函数 javascript中的thunk函数就是一个单参数函数,且该参数必须是一个callback函数,callback的签名必须为callback(err,args...); 所谓的t ...

  3. C# 图像旋转代码

    方法一: public static Bitmap rotateImage(Bitmap b, float angle) { //create a new empty bitmap to hold r ...

  4. spring执行事务提交后进行一些逻辑操作

    在使用spring事务时,我们通常会把事务内的所有操作当成是一个原子操作.也就是当整个事务内的所有代码都执行完成后, 才会将所有的数据落实到数据库中.这样做有时也会给我们造成麻烦.比如以下场景: 根据 ...

  5. 高阶函数之函数柯里化function currying

    var cost = (function(){    var args = [];    return function(){        if(arguments.length === 0){   ...

  6. json键的不能像值一样拼写的问题

    今天碰到了一个json的键不能拼写的问题 解决方法是  先把json对象作为一个字符串拼写  然后再通过eavl函数转为json对象 $(".select_date").each( ...

  7. AC日记——Flag Codeforces 16a

    A. Flag time limit per test 2 seconds memory limit per test 64 megabytes input standard input output ...

  8. AC日记——[USACO09OCT]Bessie的体重问题Bessie's We… 洛谷 P2639

    题目描述 Bessie像她的诸多姊妹一样,因为从Farmer John的草地吃了太多美味的草而长出了太多的赘肉.所以FJ将她置于一个及其严格的节食计划之中.她每天不能吃多过H (5 <= H & ...

  9. Linux 性能优化解析

    前情概述 进程调度 老板 cpu 任劳任怨的打工仔 线程 工作在做什么 可运行队列 拥有的工作清单 上下文切换 和老板沟通以便得到老板的想法并及时调整自己的工作 中断 部分工作做完以后还需要及时向老板 ...

  10. git使用笔记一:

    Get code into Bitbucket fast using the command line Set up your local directory Set up Git on your m ...