eclipse自動生成註釋的方法 – JAVA編程語言程序開發技術文章

建立一個codetemplates.xml文件,內容為


<?xml version=”1.0″ encoding=”UTF-8″?><templates><template autoinsert=”false” context=”settercomment_context” deleted=”false” description=”Comment for setter method” enabled=”true” id=”org.eclipse.jdt.ui.text.codetemplates.settercomment” name=”settercomment”>/**
 * @param ${param} : set the property ${bare_field_name}.
 */</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”>/**  
 * @title ${file_name}
 * @package ${package_name}
 * @description 用一句話描述該文件做什麼
 * @author 田瓊博  
 * @update ${date} ${time}
 * @version V1.0  
 */</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=”typecomment_context” deleted=”false” description=”Comment for created types” enabled=”true” id=”org.eclipse.jdt.ui.text.codetemplates.typecomment” name=”typecomment”>/**
 * @description 這裡用一句話描述這個類的作用
 * @version 1.0
 * @author 田瓊博
 * @update ${date} ${time}
 */


</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)
 * ${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”>/**
 * @fields ${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”>/**
 * ${tags}
 * @description 用一句話說明這個方法做什麼
 * @version 1.0
 * @author 田瓊博
 * @update ${date} ${time}
 */</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 ${bare_field_name} : return the property ${bare_field_name}.
 */</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”>/**
 * 類的構造方法
 * ${tags}
 */</template></templates>


在window->java->code style->code templates下的Code Comments中import該文件即可

發佈留言