eclipse 如何禁用eclipse注释错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2253615/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:24:27  来源:igfitidea点击:

How to disable eclipse annotation error

eclipse

提问by silverburgh

In eclipse, I get the following errors in my project:

在 Eclipse 中,我的项目中出现以下错误:

The annotation @SuppressWarningsis disallowed for this location

@SuppressWarnings此位置不允许使用注释

Can you please tell me how can I turn those errors into warnings?

你能告诉我如何将这些错误变成警告吗?

Thank you.

谢谢你。



Look like it is a bug in eclipse3.6M5. This is the code which gives me error. But it works fine in eclipse3.6M4.

看起来它是eclipse3.6M5. 这是给我错误的代码。但它在eclipse3.6M4.

package java.lang.annotation;

/**
 * Defines a meta-annotation for indicating that an annotation is automatically
 * inherited.
 *
 * @since 1.5
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface Inherited {
}

回答by tangens

If it's really a wrong location of the @SuppressWarningsthen there is not much you can do. But why should you turn that off?

如果它真的是一个错误的位置,@SuppressWarnings那么你无能为力。但是为什么要关闭它呢?

As any annotation you can use @SuppressWarningsonly in front of a class, a variable declaration, a parameter or a method declaration. All other locations will give you a compile error.

作为任何注解,您@SuppressWarnings只能在类、变量声明、参数或方法声明之前使用。所有其他位置都会给你一个编译错误。

回答by Malcolm Featonby

Project -> Properties -> Java Compiler -> Errors/Warnings.

项目 -> 属性 -> Java 编译器 -> 错误/警告。

  • Choose Annotations.
  • Change "Unhandled token in '@SuppressWarnings':" to Ignore.
  • 选择注释。
  • 将“'@SuppressWarnings'中未处理的标记:”更改为忽略。

Rebuild your project and this irritant will go away. Dirty - but given that this masks other issues in the project and waists time probably worth the time saved.

重建您的项目,这种刺激就会消失。肮脏 - 但鉴于这掩盖了项目中的其他问题,并且节省了时间,可能值得节省时间。