方法一:Eclipse中设置在建立新类时自动生成注释
windows-->preference
Java-->Code Style-->Code Templates
code-->new Java files
编辑它
windows
${filecomment}
${package_declaration}
/**
* @Author fufu
* @Time ${date} ${time}
* @Version 1.0
* <p>Description:</p>
*/
${typecomment}
${type_declaration} 3d
方法二:code
经过菜单 Window->Preference 打开参数设置面板,而后选择:
Java -> Code Style -> Code Templatesblog
在右侧选择Comments,将其中的Files项,而后选右边的"Edit",进入编辑模式: ip
进入编辑模式后就能够自定义注释了。另外能够插入一些变量,如年、日期等等。it
最后,确保 Code -> New Java files 中有:"${filecomment}"io
固然,经过“导出”和“导入”功能,你能够把本身的模板导出来在其余机器上使用。模板
以上是文件注释,类中的方法自动添加注释相似,对应于Files下面的Types。变量