[英]How do I fix or correct the “Default File Template” warning in IntelliJ Idea
IntelliJ Idea: 2016.1 Windows 10 Pro IntelliJ Idea:2016.1 Windows 10 专业版
When I create a new project or a new class in a new project, IntelliJ helpfully includes a default header containing my name and the date.当我在新项目中创建一个新项目或一个新类时,IntelliJ 会很有帮助地包含一个包含我的姓名和日期的默认标头。 However, it also highlights the code and displays a warning about the file using a "Default File Template".
但是,它还会突出显示代码并使用“默认文件模板”显示有关该文件的警告。 It suggests two ways to correct the code.
它提出了两种更正代码的方法。 Either by editing the template or by replacing it with an actual file template.
通过编辑模板或将其替换为实际文件模板。 However, neither option satisfies the warning;
但是,这两个选项都不能满足警告; nor does manually replacing the contents of the header.
也不会手动替换标题的内容。 I can't figure out a way to get rid of it.
我想不出摆脱它的方法。
I know that I can suppress the warning, but I would prefer to actually correct or fix it.我知道我可以抑制警告,但我更愿意实际更正或修复它。
Any ideas?有什么想法吗?
The point of it is to remind you to document your code by adding a description of the class.它的重点是提醒您通过添加类的描述来记录您的代码。 No matter what you set the template to, if you don't change the text that is in the template, it assumes you want a reminder to override it with some useful information.
无论您将模板设置为什么,如果您不更改模板中的文本,它都会假定您希望使用一些有用信息覆盖它的提醒。 If you are not in the habit of adorning your code with informative comments, then you can disable that particular check.
如果您不习惯用信息丰富的注释来装饰您的代码,那么您可以禁用该特定检查。
To disable the check, where you see the comment block highlighted as a warning, click in that shaded area, wait for the "light bulb" intention icon to appear near the left margin, then, when it pops up a box that says "Edit template...", instead of clicking on the words, click on the little arrow to the right of the words, and select "Disable inspection".要禁用检查,您会看到注释块突出显示为警告,请单击该阴影区域,等待“灯泡”意图图标出现在左边距附近,然后,当它弹出一个框时,显示“编辑模板...”,而不是单击单词,而是单击单词右侧的小箭头,然后选择“禁用检查”。
Just add a new line after Default Template statement which has name and date.只需在具有名称和日期的默认模板语句后添加一个新行。 Intellij considers that new line as part of documentation, and then stops complaining.
Intellij 将该新行视为文档的一部分,然后停止抱怨。
Update更新
Like this:像这样:
/**
* Created by YourName on 2017/06/11.
* THIS LINE
*/
Go to Settings -> File and Code Templates -> includes转到设置 -> 文件和代码模板 -> 包含
Update the comment to add an extra line like below..This stays even after formatting the code.更新注释以添加如下所示的额外行。即使在格式化代码后,这也会保持不变。
/**
* Created by ${USER}
* on ${DATE}.
*/
在注释中按 Alt+Enter,然后使用键盘上的向右箭头键获得一个子菜单,您可以在其中禁用 lint 检查。
Add -Djdk.util.zip.ensureTrailingSlash=false
in Help |在帮助中添加
-Djdk.util.zip.ensureTrailingSlash=false
| Edit Custom VM Options.编辑自定义 VM 选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.