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

时间:2023-01-18 10:23:21

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?

我想改变它。这可能吗?

5 个解决方案

#1


168  

Check Preferences / Java / Code Style / Code Template

检查首选项/ Java /代码样式/代码模板

Section Comment / Type

部分评论/类型

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

您可以使用您需要的任何值替换author标记,它将对新生成的类产生影响。

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


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

但是,如果模板很好,但引用的值不是作者标签,​​请参阅此SO问题:

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

$ {user}使用user.name环境变量的值;因此,您可以在eclipse.ini中传递-Duser.name = My Name来覆盖它。

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.
  • MacO:Aram Kocharyan提到eclipse.ini在Eclipse.app/Contents/MacOS/中,如果你右键单击并显示包内容。
  • ZendStudio: rofflox comments the file is named ZendStudio.ini and is found in Applications/Zend Studio.app/Contents/MacOS/.
  • ZendStudio:rofflox评论该文件名为ZendStudio.ini,可在Applications / Zend Studio.app/Contents/MacOS/中找到。

#2


6  

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

查看Window - > Preferences - > Java - > Editor - > Templates。

#3


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.

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

#4


3  

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)}。

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

#5


1  

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生成更先进。

#1


168  

Check Preferences / Java / Code Style / Code Template

检查首选项/ Java /代码样式/代码模板

Section Comment / Type

部分评论/类型

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

您可以使用您需要的任何值替换author标记,它将对新生成的类产生影响。

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


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

但是,如果模板很好,但引用的值不是作者标签,​​请参阅此SO问题:

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

$ {user}使用user.name环境变量的值;因此,您可以在eclipse.ini中传递-Duser.name = My Name来覆盖它。

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.
  • MacO:Aram Kocharyan提到eclipse.ini在Eclipse.app/Contents/MacOS/中,如果你右键单击并显示包内容。
  • ZendStudio: rofflox comments the file is named ZendStudio.ini and is found in Applications/Zend Studio.app/Contents/MacOS/.
  • ZendStudio:rofflox评论该文件名为ZendStudio.ini,可在Applications / Zend Studio.app/Contents/MacOS/中找到。

#2


6  

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

查看Window - > Preferences - > Java - > Editor - > Templates。

#3


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.

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

#4


3  

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)}。

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

#5


1  

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生成更先进。