As a programmer, the readability of the written code is very important! The readable code should not only have a standard format, but also have appropriate annotations. Each class, method, attribute, or important code segment should be annotated so that you can read the code next time or by others. In eclipse, You can automatically generate comments for classes, methods, and attributes. As for what the comment is to be displayed, you can adjust the display according to your own needs, or you can directly import the template, which is easier. The method for importing a template is described here.
First, copy the following content to generate an XML file.
<?xml version="1.0" encoding="UTF-8" standalone="no"?><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}. * @author ${user} * @update ${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"> /** * ${tags} * @description * @version 1.0 * @author ${user} * @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"> /** * @author ${user} * @update ${date} ${time} * @return ${bare_field_name} : return the property ${bare_field_name}. */ </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 ${user} * @update ${date} ${time} */ </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"> /** * Constructor Method * @author ${user} * @update ${date} ${time} * ${tags} */ </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} * @author ${user} * @update ${date} ${time} */ </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 ${user} * @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} * @author ${user} * @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} * @author ${user} * @update ${date} ${time} */ </template></templates>
Then, find the annotation template in WINDOW> preferences> JAVA> code style> code templates.
Finally, click Import to import the generated XML file and then click Apply.