[b]方法一:Eclipse中设置在创建新类时自动生成注释 [/b]
windows-->preference
Java-->Code Style-->Code Templates
code-->new Java files
编辑它
${filecomment}
${package_declaration}
/**
* @Author fufu
* @Time ${date} ${time}
* @Version 1.0
* <p>Description:</p>
*/
${typecomment}
${type_declaration}
[b]方法二:[/b]
[b]通过菜单 Window->Preference 打开参数设置面板,然后选择:[/b]
[b]Java -> Code Style -> Code Templates[/b]
[img]http://files.jb51.net/file_images/article/201702/2017020914164117.png[/img]
在右侧选择Comments,将其中的Files项,然后选右边的"Edit",进入编辑模式:
[img]http://files.jb51.net/file_images/article/201702/2017020914164218.png[/img]
进入编辑模式后就可以自定义注释了。另外可以插入一些变量,如年、日期等等。
[img]http://files.jb51.net/file_images/article/201702/2017020914164219.png[/img]
最后,确保 Code -> New Java files 中有:"${filecomment}"
[img]http://files.jb51.net/file_images/article/201702/2017020914164220.png[/img]
当然,通过“导出”和“导入”功能,你可以把自己的模板导出来在其他机器上使用。
[img]http://files.jb51.net/file_images/article/201702/2017020914164221.png[/img]
以上是文件注释,类中的方法自动添加注释类似,对应于Files下面的Types。
[b]Eclipse快捷键:选中你的方法后alt+shift+J[/b]
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持编程素材网!