IntelliJ IDEA - 省略默认的 Java 类头生成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22473707/
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
IntelliJ IDEA - omit default Java class header generation
提问by GreyCat
Every time when I use IDEA and create a Java class with normal "New Java class" menu option, it generates an ugly and useless Javadoc-style header before the class itself:
每次当我使用 IDEA 并使用普通的“新 Java 类”菜单选项创建一个 Java 类时,它都会在类本身之前生成一个丑陋且无用的 Javadoc 样式的头:
/**
* Created by greycat on 18.03.14.
*/
I might rant a lot on why is it useless, for example:
我可能会抱怨它为什么没用,例如:
- I would have authorship & timestamps in my VCS anyway
- It blatantly breaks any Javadoc documentation practices (for instance, using
@author
or@since
tag) - It uses ugly, ambiguous, locale-specific date format
- 无论如何,我的 VCS 中会有作者身份和时间戳
- 它公然破坏了任何 Javadoc 文档实践(例如,使用
@author
或@since
标记) - 它使用丑陋的、模棱两可的、特定于语言环境的日期格式
Is there a way to disable this behavior, i.e. just create normal, clean class template, without this header?
有没有办法禁用这种行为,即只创建正常的、干净的类模板,而没有这个头?
采纳答案by Geoffrey De Vylder
After the class is generated you can click on the generated text and press alt-enter. This shows you an option to edit the template.
类生成后,您可以单击生成的文本并按 alt-enter。这将向您显示编辑模板的选项。
回答by fge
The following is valid for IDEA 13.x.
以下内容适用于 IDEA 13.x。
Files -> Settings, under IDE Settings, select "File and code templates".
文件 -> 设置,在 IDE 设置下,选择“文件和代码模板”。
In the right panel, you will see several tabs: choose "Includes". There is a "File Header" entry: select this, modify and save.
在右侧面板中,您将看到几个选项卡:选择“包括”。有一个“文件头”条目:选择此项,修改并保存。
Note that this header applies to allfile types.
请注意,此标头适用于所有文件类型。
Note also that this is a separate setting from copyright notices, which you can set per project.
另请注意,这是与版权声明不同的设置,您可以为每个项目设置。
回答by lxxxvi
To change this template use File | Settings | File (and Code) Templates.
要更改此模板,请使用 File | 设置 | 文件(和代码)模板。
See also: https://www.jetbrains.com/idea/webhelp/file-and-code-templates.html
另见:https: //www.jetbrains.com/idea/webhelp/file-and-code-templates.html
回答by ROMANIA_engineer
IntelliJ IDEA 15
IntelliJ IDEA 15
Method 1
方法一
File> Settings...(or press Ctrl+ Alt+ S)
Editor> File and Code Templates> Includes> File Header> remove the comment from the right side
Method 2
方法二
Press Ctrl+ Shift+ A> type "File Header S" > choose "File Header" from "Settings" (the first line)
Remove the comment from the right side