Welcome 微信登录

首页 / 操作系统 / Linux / 配置Eclipse注释模板

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

文件(Files)注释标签:

/**   * Copyright © ${year}公司名字. All rights reserved. * * @Title: ${file_name} * @Prject: ${project_name} * @Package: ${package_name} * @Description: ${todo} * @author: ${user}   * @date: date  {time} * @version: V1.0   */

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

/** * @ClassName: ${type_name} * @Description: ${todo} * @author: ${user} * @date: date  {time} * ${tags} */

字段(Fields)注释标签:

/** * @fieldName: ${field} * @fieldType: ${field_type} * @Description: ${todo} */

构造函数标签:

/** * @Title:${enclosing_type} * @Description:${todo} * ${tags} */

方法(Constructor & Methods)标签:

/** * @Title: ${enclosing_method} * @Description: ${todo} * ${tags} * @return: ${return_type} */

覆盖方法(Overriding Methods)标签:

/* (non Javadoc) * @Title: ${enclosing_method} * @Description: ${todo} * ${tags} * ${see_to_overridden} */

代表方法(Delegate Methods)标签:

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

getter方法标签:

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

setter方法标签: 

/** * @param paramthe  {bare_field_name} to set */或者可以从网上下载配置好的.xml文件导入也可以。
 PS:在按照上面的方法设置后,一定要到windows->Preferences->general->Content Types,右侧Context Types树,点开Text,选择Java Source File,在下面的Default encoding输入框中输入UTF-8,点Update,则设置Java文件编码为UTF-8,否则会出现字符编码的问题。 经过如上的设置后,就可以使用快捷键Alt+Shift+J来快速生成文档的注释了。使用方法如下:

文件头注释:

使用New->Class方法生成的文件会在创建类的对话框选项中提示是否生成注释,默认是选中的。这样生成的.java文件就有在文件头带有上面设置的版权信息。若是使用New->File方法建立的java文件则不会自动生成文件头的版权信息,必须手动输入。

方法、类、字段等注释:

这一类的注释只需要选中方法名、类名、或字段名,然后使用Alt+Shift+J来自动生成注释,然后补全信息即可。--------------------------------------分割线 --------------------------------------Ubuntu 14.04 LTS安装Java 8和Eclipse 4.4  http://www.linuxidc.com/Linux/2014-11/109217.htmHadoop Eclipse 插件编译安装1.2.0 http://www.linuxidc.com/Linux/2013-07/87428.htmHadoop在Eclipse中的插件编译 http://www.linuxidc.com/Linux/2013-04/83295.htmHadoop 1.2.1编译Eclipse插件 http://www.linuxidc.com/Linux/2013-10/91666.htmUbuntu 13.10安装JDK、Eclipse for C/C++(解决全局菜单问题) http://www.linuxidc.com/Linux/2013-11/92305.htm如何在Ubuntu 14.04中安装最新版Eclipse  http://www.linuxidc.com/Linux/2014-08/105090.htm--------------------------------------分割线 --------------------------------------Eclipse 的详细介绍:请点这里
Eclipse 的下载地址:请点这里本文永久更新链接地址