Eclipse支持我们自定义模板,比如文件的注释,类注释,函数注释等功能。eclipse自身有自带的模板,我们也可以自己定义。一次点击:windows-》preference—》java-》code style-》code template 之后再点击import导入即可。
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><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">/** 2 * @ClassName: ${type_name} 3 * @Description: ${todo}(这里用一句话描述这个类的作用) 4 * @author ${user} 5 * @date ${date} ${time} 6 * 7 * ${tags} 8 */ </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">/** 9 * ${tags} 10 * ${see_to_target} 11 */</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">/** 12 * @param ${param} the ${bare_field_name} to set 13 */</template><template autoinsert="true" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/** 14 * @return the ${bare_field_name} 15 */</template><template autoinsert="true" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/** 16 * 17 */</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">/** 18 * @Title: ${file_name} 19 * @Package ${package_name} 20 * @Description: ${todo}(用一句话描述该文件做什么) 21 * @author ${user} 22 * @date ${date} ${time} 23 * @version V1.0 24 */ </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">/** 25 * <p>Title: ${enclosing_method}</p> 26 * <p>Description: </p> 27 * ${tags} 28 * ${see_to_overridden} 29 */ </template><template autoinsert="true" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/** 30 * ${tags} 31 */</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">/** 32 * @Title: ${enclosing_method} 33 * @Description: ${todo}(这里用一句话描述这个方法的作用) 34 * @param ${tags} 设定文件 35 * @return ${return_type} 返回类型 36 * @throws 37 */ </template></templates>