如何在 Eclipse 中设置 ${user} 以获得正确的 @author 标签?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/935711/
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
How do I set ${user} in Eclipse to get the correct @author tag?
提问by Uri
Possible Duplicate:
How to change the value of ${user} variable used in Eclipse templates
I am using Eclipse and every time code is created, @author is set to the value of ${user}. Unfortunately,${user} seems to contain my windows login id. Is there a way to override this through Eclipse? I couldn't find the option.
我正在使用 Eclipse,每次创建代码时,@author 都会设置为 ${user} 的值。不幸的是,${user} 似乎包含我的 Windows 登录 ID。有没有办法通过 Eclipse 覆盖它?我找不到选项。
回答by VonC
Windows > Preferences > Java > Code Style > Code Templates > Comments
Select Types
and edit the template to insert another value (possibly a fixed one for now, or change the user.name propertyas mmyers suggests)
选择Types
并编辑模板以插入另一个值(现在可能是固定值,或者按照 mmyers 的建议更改user.name 属性)
/**
* @author myUserValue
*
* ${tags}
*/
回答by Michael Myers
I'm not sure if there's a way in Eclipse itself. But from what I can find, ${user}
uses the value of the user.name
environment variable; therefore, you can pass -Duser.name=My Name
in eclipse.ini to override it.
我不确定 Eclipse 本身是否有办法。但据我所知,${user}
使用user.name
环境变量的值;因此,您可以传入-Duser.name=My Name
eclipse.ini 来覆盖它。
Or, if you prefer, you can modify the shortcut to point to:
或者,如果您愿意,可以修改快捷方式以指向:
C:/java/eclipse/eclipse.exe -vmargs -Duser.name="cleverUserNameToUseInSourceCode"
as shown in this blog entry.
如本博客条目所示。