在myeclipse下给代码加注释(转载)
?
转载:?http://sunboyyyl.blog.163.com/blog/static/2247381201081421216598/
给类加注释:
方法一、Window --> Java --> Code Style --> Code Templates --> Comments --> types -->edit
/**
?*类描述:
?*@author: blank
?*@date: 日期:${date} 时间:${time}
?*${tags}
?*@version 1.0
?*/
方法二、Window --> Java --> Code Style --> Code Templates --> Comments --> types -->import
<?xml version="1.0" encoding="UTF-8"?>
?<templates>
???? <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">
?/**
? * [Product]
? *???? ${project_name}
? * [Copyright]
? *???? Copyright ? ${year} ICSS All Rights Reserved.
? * [FileName]
? *???? ${file_name}
? * [History]
? *???? Version? Date????? Author???? Content
? *???? -------- --------- ---------- ------------------------
? *???? 1.0.0??? ${date}?? ${user}??? 最初版本
? */</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">
?/**
? * <b>Summary: </b>
? *????? TODO 请在此处简要描述此类所实现的功能。因为这项注释主要是为了在IDE环境中生成tip帮助,务必简明扼要
? * <b>Remarks: </b>
? *??????? TODO 请在此处详细描述类的功能、调用方法、注意事项、以及与其它类的关系
? */</template>
? <!-- 构造函数注释 -->
???? <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">
?/**?
? * <b>Summary: </b>
? *???? 构造一个 ${enclosing_type}??
? * <b>Remarks: </b>
? *???? 构造类 ${enclosing_type} 的构造函数 ${enclosing_type}
? * ${tags}?
? */</template>
? <!-- GET方法注释 -->
???? <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">
?/**
? * <b>Summary: </b>
? *???? 获取${bare_field_name}的值
? * @return ${bare_field_name}?
? */</template>
? <!-- SET方法注释 -->
???? <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">
?/**?
? * <b>Summary: </b>
? *???? 设置 ${bare_field_name} 的值?
? * @param ${param}?
? */</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">
?/**
? * <b>Summary: </b>
? *???? ${enclosing_method}(请用一句话描述这个方法的作用)
? * ${tags}?
? */</template>
? <!-- 代理方法注释 -->
???? <template?
???????? autoinsert="true"?
???????? context="delegatecomment_context"
???????? deleted="false"?
???????? description="Comment for delegate methods"
???????? enabled="true"
???????? id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"
???????? name="delegatecomment">
?/**?
? * <b>Summary: </b>
? *???? 代理方法 ${enclosing_method}
? * ${tags}?
? * ${see_to_target}?
? */</template>
? <!-- 复写方法注释 -->
???? <template?
???????? autoinsert="true"?
???????? context="overridecomment_context"
???????? deleted="false"?
???????? description="Comment for overriding methods"
???????? enabled="true"
???????? id="org.eclipse.jdt.ui.text.codetemplates.overridecomment"
???????? name="overridecomment">
?/**?
? * <b>Summary: </b>
? *???? 复写方法 ${enclosing_method}
? * ${tags}?
? * ${see_to_overridden}?
? */</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}:${todo}(请用一句话描述这个变量表示什么)?
? */</template>
?</templates>
保存为xml文件,导入即可
问题:日期格式不对。日期:Sep 14, 2010 时间:1:58:41 PM
办法:
找到eclipse.ini?
里面有-Duser.language=en?
改为-Duser.language=zh-cn即可
如:${date} ${time}? 输出的注释格式为:2009-10-15 上午10:36:08
?