- 设置注释模板的步骤:点击菜单栏上的Window -->Preferences-->Java-->Code Style -->Code Templates
- 常用的注解介绍:
@author 作者名
@date 日期
@version 版本标识
@parameter 参数及其意义
@return 返回值
@throws 异常类及抛出条件
@deprecated 引起不推荐使用的警告
@override 重写
- Comment详细设置
① Comments下的Files设置
/**
* <p>Title: ${file_name}</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2017</p>
* <p>Company: www.baidudu.com</p>
* @author xianxian
* @date ${date}
* @version 1.0
*/
②Types:对类进行注释
/**
* <p>Title: ${type_name}</p>
* <p>Description: </p>
* @author xianxian
* @date ${date}
*/
③Fields:对字段进行注释
/**
* ${field}
*/
④Constructors:对构造方法进行注释
/**
* <p>Title: </p>
* <p>Description: </p>
* ${tags}
*/
⑤Methods:对方法进行注释
/**
* <p>Title: ${enclosing_method}</p>
* <p>Description: </p>
* ${tags}
*/
⑥Overriding Methods:对重写方法进行注释
/* (non-Javadoc)
* <p>Title: ${enclosing_method}</p>
* <p>Description: </p>
* ${tags}
* ${see_to_overridden}
*/
⑦ Delegate methods:对代表方法进行注释
/**
* ${tags}
* ${see_to_target}
*/
⑧Getters:对get方法进行注释
/**
* @return the ${bare_field_name}
*/
⑨Setters:对set方法进行注释
/**
* @param ${param} the ${bare_field_name} to set
*/
最后:
- 注释模板的导出(导入不作介绍)
codetemplates.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="false" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/**
* <p>Title: </p>
* <p>Description: </p>
* ${tags}
*/</template><template autoinsert="false" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/**
* ${tags}
* ${see_to_target}
*/</template><template autoinsert="false" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/**
* <p>Title: ${file_name}</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2017</p>
* <p>Company: www.baidudu.com</p>
* @author xianxian
* @date ${date}
* @version 1.0
*/ </template><template autoinsert="false" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/* (non-Javadoc)
* <p>Title: ${enclosing_method}</p>
* <p>Description: </p>
* ${tags}
* ${see_to_overridden}
*/</template><template autoinsert="false" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/**
* @return the ${bare_field_name}
*/</template><template autoinsert="false" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/**
* ${field}
*/ </template><template autoinsert="false" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/**
* <p>Title: ${enclosing_method}</p>
* <p>Description: </p>
* ${tags}
*/ </template><template autoinsert="true" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">/**
* @param ${param} the ${bare_field_name} to set
*/</template><template autoinsert="false" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/**
* <p>Title: ${type_name}</p>
* <p>Description: </p>
* @author xianxian
* @date ${date}
*/ </template></templates>
- Java注释模板的使用
我常用的是直接输入/*而后按下确定键后就可以自动生成
参考链接:
==================================================================
分割线
==================================================================
博主为咯学编程:父母不同意学编程,现已断绝关系;恋人不同意学编程,现已分手;亲戚不同意学编程,现已断绝来往;老板不同意学编程,现已失业三十年。。。。。。如果此博文有帮到你欢迎打赏,金额不限。。。
网友评论