How do I change the Javadocs template generated in Eclipse?

别说谁变了你拦得住时间么 提交于 2019-11-27 04:13:16

问题


I dislike the default Javadocs generated for me when I create a Class or methods, especially the @author variable, which is the current system username on my windows box.

I would like to change it. Is this possible?


回答1:


Check Preferences / Java / Code Style / Code Template

Section Comment / Type

You can replace the author tag by whatever value you need and it will have an effect on new generated classes.


However, if the template is fine, but the value referenced buy the author tag is not, see this SO question:

${user} uses the value of the user.name environment variable; therefore, you can pass -Duser.name=My Name in eclipse.ini to override it.

Or, if you prefer, you can modify the shortcut to point to:

C:/java/eclipse/eclipse.exe -vmargs -Duser.name="cleverUserNameToUseInSourceCode"

  • MacOs: Aram Kocharyan mentions the eclipse.ini is in Eclipse.app/Contents/MacOS/ if you right click and go Show Package Content.
  • ZendStudio: rofflox comments the file is named ZendStudio.ini and is found in Applications/Zend Studio.app/Contents/MacOS/.



回答2:


Look at Window -> Preferences -> Java -> Editor -> Templates.




回答3:


Spring Tool Suite (popular Eclipse customization for Spring development) uses STS.ini. On Windows I found it in the same dir as an app launch executable.




回答4:


To use a Git username and email you can use the variables ${name:git_config(user.name)} and ${email:git_config(user.email)}.




回答5:


You should consider using JAutodoc, which is a very useful plugin for Eclipse. The parametrization is way more advanced than the standard Eclipse generation.



来源:https://stackoverflow.com/questions/2612633/how-do-i-change-the-javadocs-template-generated-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!