如何更改 Eclipse 中生成的 Javadocs 模板?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2612633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 09:53:03  来源:igfitidea点击:

How do I change the Javadocs template generated in Eclipse?

javaeclipsetemplatesjavadoc

提问by Olaseni

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.

我不喜欢在创建类或方法时为我生成的默认 Javadoc,尤其是 @author 变量,它是我的 windows 框上的当前系统用户名。

I would like to change it. Is this possible?

我想改变它。这可能吗?

采纳答案by VonC

Check Preferences / Java / Code Style / Code Template

查看 Preferences / Java / Code Style / Code Template

Section Comment / Type

部分 Comment / Type

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

你可以用author你需要的任何值替换标签,它会对新生成的类产生影响。

Code Templates

代码模板



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.nameenvironment variable; therefore, you can pass -Duser.name=My Namein eclipse.inito override it.

${user}使用user.name环境变量的值;因此,你可以通过-Duser.name=My Nameeclipse.ini覆盖它。

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

或者,如果您愿意,可以修改快捷方式以指向:

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


  • MacOs: Aram Kocharyanmentionsthe eclipse.iniis in Eclipse.app/Contents/MacOS/if you right click and go Show Package Content.
  • ZendStudio: roffloxcommentsthe file is named ZendStudio.iniand is found in Applications/Zend Studio.app/Contents/MacOS/.
  • Mac系统:阿兰·科恰良提到eclipse.iniEclipse.app/Contents/MacOS/,如果你右击并去显示包内容。
  • ZendStudio:rofflox注释该文件已命名ZendStudio.ini并位于Applications/Zend Studio.app/Contents/MacOS/.

回答by Binil Thomas

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

查看窗口 -> 首选项 -> Java -> 编辑器 -> 模板。

回答by Julien

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

您应该考虑使用JAutodoc,这是一个非常有用的 Eclipse 插件。参数化比标准的 Eclipse 代更先进。

回答by Alexey Slepov

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.

Spring Tool Suite(用于 Spring 开发的流行 Eclipse 定制)使用 STS.ini。在 Windows 上,我发现它与应用程序启动可执行文件位于同一目录中。

回答by chrisjleu

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

要使用 Git 用户名和电子邮件,您可以使用变量${name:git_config(user.name)}${email:git_config(user.email)}.

enter image description here

在此处输入图片说明