JavaBean is usually used when coding, while we often write comments on the field, but the generated Get/set method will not be generated, by modifying the Eclipse source code can be resolved, directly on the example:
/*** Employee ID*/ PrivateString userid; /*** Get Employee ID *@returnUserID Employee ID*/ PublicString GetUserid () {returnuserid; } /*** Set Employee ID *@paramUserID Employee ID*/ Public voidSetuserid (String userid) { This. UserID =userid; }
Find the jar package in Eclipse: Org.eclipse.jdt.ui_*.jar, make a backup
The suffix jar is then changed to RAR,
Find Org.eclipse.jdt.internal.corext.codemanipulation.GetterSetterUtil.class
Replace it with the class file in the attachment, and replace the suffix with the jar for the Eclipse jar package.
Restart Eclipse Settings Annotation style:
Window->preferences->java->codestyle->code templates->comments->getters/setters
Note that the eclipse must be closed when replacing
Open Eclipse/plugins/org.eclipse.jdt.ui_*.jar with WinRAR
Replace Org.eclipse.jdt.internal.corext.codemanipulation.GetterSetterUtil class
Then start eclipse
Getters:
/** * Get ${bare_field_name} @return ${bare_field_name} ${bare_field_name} */
Setters:
/** * Set ${bare_field_name} @param ${bare_field_name} ${bare_field_name} * /
Note: The Get/set method is generated by checking the Generate methods comments
OK, success.
In the eclipse3.3/3.4/3.5 test succeeds, if useless restore jar package, find the corresponding version source code to modify.
- Gettersetterutil.rar (9.1 KB)
- Download number of times: 26
- Gettersetterutil_eclipse3.5.rar (9.8 KB)
- Download number of times: 15
Eclipse Get set automatically adds comments