39

IDEA修改类注释自动生成的用户名

 5 years ago
source link: http://www.zhyea.com/2018/07/10/idea-alter-author-in-java-doc.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

使用IDEA时,自动生成的类注释中的用户名默认为操作系统当前的用户名。这样的用户名通常和实际要用的用户名是不一致的。

已知的有两种调整方式。

第一种方式在File -> Settings -> Editor -> File and Code Templates –> Class –>Includes –>File Header 添加固定的author注释即可。如下:

/**
 *
 * @author 用户名
 */

不过我并不喜欢这种固定写死的方式。在idea中,对应用户名的变量是“${USER}”,这个变量对应的虚拟机参数是“-Duser.name”。要调整这个参数,在网上找到的方式多是修改idea安装目录下的“\bin\idea.exe.vmoptions”文件,在最后一行添加“-Duser.name=用户名”这种做法。

不过这种方式在较新版本的idea中并不适用。可用的方式是在IDEA的菜单中选择 Help –> Edit Custom VM Options, 然后点击确定,在idea的用户目录中创建一个新的idea.exe.vmoptions文件,在编辑器中为这个文件的最后一行添加“-Duser.name=用户名”。

再次调整File Header为如下格式:

/**
 *
 * @author ${USER}
 */

然后保存重启即可。

#####


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK