天天看点

Eclipse导入注释模板

Eclipse设置类+接口+方法注释模板

  • ​​1.先写一个xml模板​​
  • ​​2.导入模板​​
  • ​​3.使用​​
  • ​​新建类或者接口的时候一定要勾选最后一个​​
  • ​​新建方法之后按alt+shift+j​​
  • ​​修改描述即可​​

1.先写一个xml模板

<?xml version="1.0" encoding="UTF-8"?>
<templates><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="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">
 /**
 * Method name: ${enclosing_type}<BR>
 * Description: please write your description<BR>
 * ${tags} <BR>
 */</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">
 /*
 * All rights Reserved, Copyright (C) 公司名 LIMITED 2019
 * FileName: ${file_name}
 * Version:  1.0
 * Modify record:
 * NO. |     Date       |    Name        |      Content
 * 1   | ${date}        | 公司名)${user}    | original version
 */</template><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">
 /**
 * Method name: ${enclosing_method} <BR>
 * Description: please write your description <BR>
 * @param  ${param} ${field_type} <BR>
 */</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">
/**  &#13;
 * define a field ${field} which type is ${field_type}&#13;
 */</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">
/**
 * class name: ${type_name} <BR>
 * class description: please write your description <BR>
 * @version 1.0  ${date} ${time}
 * @author 公司名)Jack魏(你的姓名)
 */</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">
 /**
 * Method name: ${enclosing_method} <BR>
 * Description: ${enclosing_method} <BR>
 * ${tags}  ${return_type}<BR>
 */</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">
 /**
 * @Override
 * ${see_to_overridden} <BR>
 * Method name: ${enclosing_method} <BR>
 * Description: please write your description <BR>
 * Remark: <BR>
 * ${tags}  <BR>
*/</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">
/**
 * Method name: ${enclosing_method} <BR>
 * Description: please write your description <BR>
 * @return ${field_type} <BR>
 */</template></templates>      

2.导入模板

Eclipse导入注释模板
Eclipse导入注释模板

3.使用

新建类或者接口的时候一定要勾选最后一个

新建方法之后按alt+shift+j

修改描述即可