1、将codetemplate.xml文件中的所有 ${user} 改成自己的用户名,比如 justin.xu,保存
如下图所示:
2、eclipse 中菜单 window ---preferences
点击import 导入codetemplate.xml文件。
3、在方法名上输入 /** ,然后回车。出现模板注释。
4、codetemplate.xml文件内容如下:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><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>
* Description:这里写描述<br />
* </p>
* @author ${user}
* @version 0.1 ${date}
* ${tags}
* ${return_type}
*/</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">/**
* @fields ${field}
*/
</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">/**
* constructer
* ${tags}
*/</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">/* (non-Javadoc)
* ${see_to_overridden}
*/</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>
* Description:这里写描述<br />
* </p>
* @title ${file_name}
* @package ${package_name}
* @author ${user}
* @version 0.1 ${date}
*/</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">/**
* @return ${bare_field_name} : return the property ${bare_field_name}.
*/</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} : set the property ${bare_field_name}.
*/</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">/**
* ${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">/**
* <p>
* Description:这里写描述<br />
* </p>
* @title ${file_name}
* @package ${package_name}
* @author ${user}
* @version 0.1 ${date}
*/
</template></templates>