简体   繁体   English

如何修复或更正 IntelliJ Idea 中的“默认文件模板”警告

[英]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
 */

Change the default template anyway you want and then the error is gone!随意更改默认模板,然后错误就消失了!

在此处输入图片说明

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.

相关问题 如何在Intellij Idea中集成Bootstrap模板? - How do I integrate a Bootstrap template in Intellij Idea? 如何插入模板以使用intellij idea编写代码 - How do I insert a template to write code on with intellij idea 如何更改 IntelliJ IDEA 默认 JDK? - How do I change the IntelliJ IDEA default JDK? 如何在 IntelliJ IDEA 中默认将文件夹指定为源文件夹? - How do I designate a folder as a Source folder by default in IntelliJ IDEA? 如何解决 IntelliJ IDEA 中 Java 文件的依赖冲突? - How do I resolve dependency conflict for a Java file in IntelliJ IDEA? 如何将.jar文件添加到IntelliJ IDEA Java项目中? - How do I add a .jar file into an IntelliJ IDEA Java project? 如何从 Intellij 创意项目制作可执行文件? - How do I make an executable file from an intellij idea project? 如何修复“任务 'compileJava' 执行失败”错误。 (使用 Intellij Idea 和 Gradle) - How do I fix “Execution failed for task 'compileJava'” error. (Using Intellij Idea and Gradle) 如何在 IntelliJ IDEA 中修复“不支持的 class 文件主要版本 60”? - How can I fix "unsupported class file major version 60" in IntelliJ IDEA? 如何在IntelliJ IDEA中将2条语句重构为1条 - How do I refactor 2 statements to 1 in IntelliJ IDEA
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM