eclipse 注释配置
时间:2022-04-03 09:42
最近公司新起了一个项目,开发人员4人,为统一注释风格,特意研究了下eclipse下的注释方法和规范
因为只是配置,就不做太多解释了
1.设置注释模板的入口: Window->Preference->Java->Code Style->Code Template
直接用import导入,链接是我整理的一个简单模板
<?xml version="1.0" encoding="UTF-8" standalone="no"?><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} delegate methods
* ${see_to_target}
*/
</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="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">
/**
* Description
* constructors
* ${tags}
*/
</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">/**
* @Description
* @author ${user}
* @date ${date} ${time}
* ${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">/**
* @Description:
* @Title: ${file_name}
* @Package: ${package_name}
* @author: ${user}
* @date ${date} ${time}
*/
</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">
/**
* @Description
* @author ${user}
* ${tags}
*/
</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
* @author ${user}
* @date ${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}
*/
</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">
/**
* @param ${param} 要设置的 ${bare_field_name}
*/
</template></templates>
2.注意在code Template设置界面 勾选Automatically add comments for new methods and types
3.eclipse.ini 文件中,
-vmargs
-Duser.name=你的名字