为什么 IntelliJ IDEA 会发出此文件 javadoc 悬空的警告?
Why does IntelliJ IDEA give a warning that this file javadoc is dangling?
我正在使用 IntelliJ IDEA,我尝试在文件顶部添加 Javadoc 注释,如下所示:
/**
* @file ProcessJson.java
* @author Tim Sloane
* @date 2017-05-09
*/
但是 IntelliJ 给了我警告 "Dangling Javadoc comment." 是什么让这个评论悬而未决?我想因为它是用@file标记的,所以它应该在文件的开头。
Javadoc 没有@file 或@date 标签。您应该标记 class,而不是。
/**
* Description of the class goes here.
*
* @author Tim Sloane
*/
public class ProcessJson {
参见:
http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html
花点时间阅读这个警告的扩展帮助,强调我的:
Reports dangling Javadoc comments. Javadoc comments are dangling if they don't belong to any class, method or field. For example a Javadoc comment in between method declarations that have their own Javadoc comments.
您的 Javadoc 注释不属于 class、方法或字段,因此它确实悬而未决。 @file
标签 doesn't exist,所以完全不需要添加。
或者,您可以删除 一个 星号并且 没有 有 Javadoc,从而使 IntelliJ 在这件事上保持沉默...
以防万一,如果您有兴趣删除这个悬而未决的 Java文档评论检查,您可以通过禁用它来实现:
- 打开首选项
- 导航至编辑器 --> 检查
- 右侧菜单列表下,select Java --> JavaDoc
- 取消选中 "Dangling Javadoc comment"
如果您将 Javadoc 注释放在任何注释之后,您也会看到这一点。
例如:
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuppressWarnings({"unused", "WeakerAccess"})
/** --> Dangling Javadoc warning.
* This class does great and wonderful things.
*/
public class ClassThatDoesStuff {
}
相反,Javadoc 必须先于所有内容才能获得 "No errors found in this file" 批准印章:
/**
* This class does great and wonderful things.
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuppressWarnings({"unused", "WeakerAccess"})
public class ClassThatDoesStuff {
}
Intellij Idea 给你警告“悬挂Java文档评论”,
1-如果您在 Javadoc
之后插入 classes 导入声明:
/**
* @author Elyas 'Eloy' Hadizadeh Tasbiti
* Created in 3/16/20, 1:15 PM.
*/
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/")
public class HomeController
{}
2-如果您将 Java 文档注释放在 class 级注释之后:
@Controller
@RequestMapping("/")
/**
* @author Elyas 'Eloy' Hadizadeh Tasbiti
* Created in 3/16/20, 1:15 PM.
*/
public class HomeController
{}
3-如果您使用 JavaDoc.
无法理解的不当标签,例如 @file
或 @date
虽然您可以跳过这些警告或通过省略第一行中的一个星号将 Java-doc 注释更改为常规注释,但我强烈建议您使用 Java-docs可以非常有帮助并在 HTML.
中生成标准文档
我正在使用 IntelliJ IDEA,我尝试在文件顶部添加 Javadoc 注释,如下所示:
/**
* @file ProcessJson.java
* @author Tim Sloane
* @date 2017-05-09
*/
但是 IntelliJ 给了我警告 "Dangling Javadoc comment." 是什么让这个评论悬而未决?我想因为它是用@file标记的,所以它应该在文件的开头。
Javadoc 没有@file 或@date 标签。您应该标记 class,而不是。
/**
* Description of the class goes here.
*
* @author Tim Sloane
*/
public class ProcessJson {
参见:
http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html
花点时间阅读这个警告的扩展帮助,强调我的:
Reports dangling Javadoc comments. Javadoc comments are dangling if they don't belong to any class, method or field. For example a Javadoc comment in between method declarations that have their own Javadoc comments.
您的 Javadoc 注释不属于 class、方法或字段,因此它确实悬而未决。 @file
标签 doesn't exist,所以完全不需要添加。
或者,您可以删除 一个 星号并且 没有 有 Javadoc,从而使 IntelliJ 在这件事上保持沉默...
以防万一,如果您有兴趣删除这个悬而未决的 Java文档评论检查,您可以通过禁用它来实现:
- 打开首选项
- 导航至编辑器 --> 检查
- 右侧菜单列表下,select Java --> JavaDoc
- 取消选中 "Dangling Javadoc comment"
如果您将 Javadoc 注释放在任何注释之后,您也会看到这一点。
例如:
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuppressWarnings({"unused", "WeakerAccess"})
/** --> Dangling Javadoc warning.
* This class does great and wonderful things.
*/
public class ClassThatDoesStuff {
}
相反,Javadoc 必须先于所有内容才能获得 "No errors found in this file" 批准印章:
/**
* This class does great and wonderful things.
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuppressWarnings({"unused", "WeakerAccess"})
public class ClassThatDoesStuff {
}
Intellij Idea 给你警告“悬挂Java文档评论”,
1-如果您在 Javadoc
之后插入 classes 导入声明:
/**
* @author Elyas 'Eloy' Hadizadeh Tasbiti
* Created in 3/16/20, 1:15 PM.
*/
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/")
public class HomeController
{}
2-如果您将 Java 文档注释放在 class 级注释之后:
@Controller
@RequestMapping("/")
/**
* @author Elyas 'Eloy' Hadizadeh Tasbiti
* Created in 3/16/20, 1:15 PM.
*/
public class HomeController
{}
3-如果您使用 JavaDoc.
无法理解的不当标签,例如@file
或 @date
虽然您可以跳过这些警告或通过省略第一行中的一个星号将 Java-doc 注释更改为常规注释,但我强烈建议您使用 Java-docs可以非常有帮助并在 HTML.
中生成标准文档