Java 如何在不更改操作系统用户名的情况下更改 IntelliJ IDEA 中的 ${USER} 变量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33138979/
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 to change ${USER} variable in IntelliJ IDEA without changing OS user name?
提问by Cherry
采纳答案by Stanislav
You can modify the file idea.exe.vmoptionsor idea64.exe.vmoptions, which should be in the bin folder of your IDE installation. For linux version, it could be idea.vmoptions. You need to add there a parameter:
您可以修改idea.exe.vmoptions或idea64.exe.vmoptions文件,该文件应位于IDE 安装的bin 文件夹中。对于 linux 版本,它可能是idea.vmoptions。您需要在那里添加一个参数:
-Duser.name=YOURNAME
This would make your ${USER}
variable inside IntelliJ Idea equals to parameter value and you don't have to change the current OS user login name. I've just tested it in the IntelliJ Idea 14.1.3 with file and code templates.
这将使您${USER}
在 IntelliJ Idea 中的变量等于参数值,并且您不必更改当前的操作系统用户登录名。我刚刚在 IntelliJ Idea 14.1.3 中使用文件和代码模板对其进行了测试。
回答by Alex Dioso
To change the ${USER} variable for just the current user (rather than system wide) select Help->Edit Custom VM Options and add the following to the file that opens in your editor:
要仅为当前用户(而不是系统范围)更改 ${USER} 变量,请选择 Help->Edit Custom VM Options 并将以下内容添加到在编辑器中打开的文件中:
-Duser.name=USER
Then save the file and restart your editor.
然后保存文件并重新启动编辑器。