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

eclipse中快速写入javadoc的快捷键是 ALT + SHIFT + J

文件(Files)注释标签:

  1. /**
  2. * @Description: ${todo}(用一句话描述该文件做什么)
  3. * @author ${user}
  4. * @date ${date}
  5. * @version V1.0
  6. */

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

/**
*
*
* @author ${user}
* @date ${date}
*/

字段(Fields)注释标签:

  1. /**
  2. * @Fields ${field} : ${todo}(用一句话描述这个变量表示什么)
  3. */

构造函数(Constructor)标签:

  1. /**
  2. * 创建一个新的实例 ${enclosing_type}.
  3. *
  4. * ${tags}
  5. */

方法(Methods)标签:

/**
*
*
* ${tags}
*/

覆盖方法(Overriding Methods)标签:

/*
*
*
* ${tags}
*/

代理方法(Delegate Methods)标签:

  1. /**
  2. * ${tags}
  3. * ${see_to_target}
  4. */

getter方法标签:

  1. /**
  2. * @return ${bare_field_name}
  3. */

setter方法标签:

  1. /**
  2. * @param ${param} the ${bare_field_name} to set
  3. */

要实现上面的注释模板,这需要将下面的配置文件导入就可以了:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <templates>
  3. <template
  4. autoinsert="false"
  5. context="filecomment_context"
  6. deleted="false"
  7. description="Comment for created Java files"
  8. enabled="true"
  9. id="org.eclipse.jdt.ui.text.codetemplates.filecomment"
  10. name="filecomment">
  11. /**
  12. * @Description: ${todo}(用一句话描述该文件做什么)
  13. * @author ${user}
  14. * @date ${date}
  15. * @version V1.0
  16. */
  17. </template>
  18. <template
  19. autoinsert="false"
  20. context="typecomment_context"
  21. deleted="false"
  22. description="Comment for created types"
  23. enabled="true"
  24. id="org.eclipse.jdt.ui.text.codetemplates.typecomment"
  25. name="typecomment">
  26. /**
  27. * @Description: ${todo}(这里用一句话描述这个类的作用)
  28. * @author ${user}
  29. * @date ${date}
  30. *
  31. * ${tags}
  32. */
  33. </template>
  34. <template
  35. autoinsert="false"
  36. context="fieldcomment_context"
  37. deleted="false"
  38. description="Comment for fields"
  39. enabled="true"
  40. id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment"
  41. name="fieldcomment">
  42. /**
  43. * @Fields ${field} : ${todo}(用一句话描述这个变量表示什么)
  44. */
  45. </template>
  46. <template
  47. autoinsert="false"
  48. context="constructorcomment_context"
  49. deleted="false"
  50. description="Comment for created constructors"
  51. enabled="true"
  52. id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment"
  53. name="constructorcomment">
  54. /**
  55. * 创建一个新的实例 ${enclosing_type}.
  56. *
  57. * ${tags}
  58. */
  59. </template>
  60. <template
  61. autoinsert="false"
  62. context="methodcomment_context"
  63. deleted="false"
  64. description="Comment for non-overriding methods"
  65. enabled="true"
  66. id="org.eclipse.jdt.ui.text.codetemplates.methodcomment"
  67. name="methodcomment">
  68. /**
  69. * @Title: ${enclosing_method}
  70. * @Description: ${todo}(这里用一句话描述这个方法的作用)
  71. * @param ${tags} 参数
  72. * @return ${return_type} 返回类型
  73. * @throws
  74. */
  75. </template>
  76. <template
  77. autoinsert="true"
  78. context="overridecomment_context"
  79. deleted="false"
  80. description="Comment for overriding methods"
  81. enabled="true"
  82. id="org.eclipse.jdt.ui.text.codetemplates.overridecomment"
  83. name="overridecomment">
  84. /* (非 Javadoc)
  85. * <p>Title: ${enclosing_method}</p>
  86. * <p>Description: </p>
  87. * ${tags}
  88. * ${see_to_overridden}
  89. */
  90. </template>
  91. <template
  92. autoinsert="true"
  93. context="delegatecomment_context"
  94. deleted="false"
  95. description="Comment for delegate methods"
  96. enabled="true"
  97. id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"
  98. name="delegatecomment">
  99. /**
  100. * ${tags}
  101. * ${see_to_target}
  102. */
  103. </template>
  104. <template
  105. autoinsert="false"
  106. context="gettercomment_context"
  107. deleted="false"
  108. description="Comment for getter method"
  109. enabled="true"
  110. id="org.eclipse.jdt.ui.text.codetemplates.gettercomment"
  111. name="gettercomment">
  112. /**
  113. * @return ${bare_field_name}
  114. */
  115. </template>
  116. <template
  117. autoinsert="true"
  118. context="settercomment_context"
  119. deleted="false"
  120. description="Comment for setter method"
  121. enabled="true"
  122. id="org.eclipse.jdt.ui.text.codetemplates.settercomment"
  123. name="settercomment">
  124. /**
  125. * @param ${param} the ${bare_field_name} to set
  126. */
  127. </template>
  128. </templates>

Java Code Template的更多相关文章

  1. 玩转Eclipse — 自动代码生成的Java Code Template

    文章转载地址:点击打开链接 当代码写到一定程度之后,就会发现很多代码都被重复地敲了N多遍,甚至毫不夸张地说:闭着眼睛都能敲出来.大量地敲这些重复地代码,除了锻炼敲键盘的速度,基本上没有其他益处,但是长 ...

  2. 使用MyEclipse生成Java注释时,使用的Code Template

    设置注释模板的入口: Window->Preference->Java->Code Style->Code Template, 然后展开Comments节点就是所有需设置注释的 ...

  3. Eclipse Code Template 设置自动加注释(转)

    Eclipse Code Template 设置自动加注释 设置注释模板的入口: Window->Preference->Java->Code Style->Code Temp ...

  4. Java Code Style

    近期困惑于团队成员代码风格迥异,代码质量不可控,作为一名老司机,忧患于后期服务的可维护性,多次一对一的代码Review,耗时耗力不说,效果也不明显.痛定思痛,多次反思之后得出结论:无规矩不成方圆,可靠 ...

  5. Eclipse设置代码模板Code Template

    团队协作最好是使用相同的代码模板 Code Template,打开 Window -> Preference -> Java -> Code Style -> Code Tem ...

  6. Java语言编码规范(Java Code Conventions)

    Java语言编码规范(Java Code Conventions) 名称 Java语言编码规范(Java Code Conventions) 译者 晨光(Morning) 简介 本文档讲述了Java语 ...

  7. java code to byte code--partone--reference

    Understanding how Java code is compiled into byte code and executed on a Java Virtual Machine (JVM) ...

  8. [转]Java Code Examples for android.util.JsonReader

    [转]Java Code Examples for android.util.JsonReader The following are top voted examples for showing h ...

  9. SQL to Java code for Elasticsearch

    Elasticsearch虽然定位为Search Engine,但是因其可以持久化数据,很多时候,我们把Elasticsearch当成Database用,但是Elasticsearch不支持SQL,就 ...

随机推荐

  1. 【转】VC调试的时候 “没有调试信息,未加载符号”

    概述调试是一个程序员最基本的技能,其重要性甚至超过学习一门语言.不会调试的程序员就意味着他即使会一门语言,却不能编制出任何好的软件.这里我简要的根据自己的经验列出调试中比较常用的技巧,希望对大家有用. ...

  2. Oracle字符串分割Split(超简单一条sql解决)

    ) FROM renyuan where name ='张三' 解决如下问题 我现在有一个字段是存:,,3的,而它对应另一张值集表中.eg; 课程人员表 renyuan id name Course ...

  3. 对于try catch放在能够很好地处理例外的位置

    Exception有一个message属性.在使用catch的时候可以调用: Catch(IOException e){System.out.println(e.message())}; Catch( ...

  4. 辛星和您一起解析PHP中的单例模式

    事实上单例模式还是用的挺多的,要说到最经典的样例.可能就是操纵数据库的类了,它假设是单例的话,能够避免大量的new操作消耗资源,而假设系统中须要一个类来管理全局的信息,则把它用成单例也是非常不错的.由 ...

  5. Loadrunner_http长连接设置

    最近协助同事解决了几个问题,也对loadrunner的一些设置加深了理解,关键是更加知其所以然. ljonathan http://www.51testing.com/html/48/202848-2 ...

  6. STL容器:list双向链表学习

    list是一个双向列表容器,完成了标准C++数据结构中链表的所有功能; list与vector和deque类似,只不过其中的对象提供了对元素的随机访问. STL以双向链表的方式实现list,访问需要从 ...

  7. 在Sql2000 sql2005 sql2008 下已能实现事务复制的强制订阅,但请求订阅始终不能实现总有下列错误提示

    硬件环境 : 一台服务器 安装了 sqlserver2008 数据库 局域网还有一台机器 安装了 sqlserver2000数据库 两台server 通信 共享均没有问题 同步过程中遇到的问题  : ...

  8. Git------Commit和Push的区别

    转载:http://wenda.so.com/q/1435946424728324?src=140 git作为支持分布式版本管理的工具,它管理的库(repository)分为本地库.远程库. git ...

  9. iOS开发之--苹果个人开发者账号如何升级成公司账号

    1.拨打苹果针对中国区开发者的咨询服务热线:4006 701 855 2.简单向对方(中文不太标准,但听懂没问题)说明意图后,会要求提供: (1)之前申请IDP时purchase form上的pers ...

  10. Perfmon - Windows 自带系统监测工具

    本文转载自oscar999 一. 简述 可以用于监视CPU使用率.内存使用率.硬盘读写速度.网络速度等. Perfmon提供了图表化的系统性能实时监视器.性能日志和警报管理,系统的性能日志可定义为二进 ...