方法一:Eclipse中设置在创建新类时自动生成注释 


windows-->preference 
Java-->Code Style-->Code Templates 
code-->new Java files 
编辑它 

${filecomment} 
${package_declaration} 
/** 
* @author 作者 E-mail: 
* @version 创建时间:${date} ${time} 
* 类说明 
*/ 
${typecomment} 
${type_declaration} 

方法二:

通过菜单 Window->Preference 打开参数设置面板,然后选择:
Java -> Code Style -> Code     Templates



在右侧选择Comments,将其中的Files项,然后选右边的"Edit",进入编辑模式:   



进入编辑模式后就可以自定义注释了。另外可以插入一些变量,如年、日期等等。



最后,确保 Code -> New Java files 中有:"${filecomment}"



当然,通过“导出”和“导入”功能,你可以把自己的模板导出来在其他机器上使用。




    以上是文件注释,类中的方法自动添加注释类似,对应于Files下面的Types。

 
Eclipse快捷键:选中你的方法后alt+shift+J

posted on 2011-03-29 11:30  dartagnan  阅读(107059)  评论(1编辑  收藏  举报