您的位置:首页 > 编程语言 > Java开发

Java_注解_异常_01_ElementType cannot be resolved to a variable

2017-09-20 15:22 405 查看

一、异常现象:

自定义注解时,

@Retention和@Target都能导入进来,但是却报下列错误:

RetentionPolicy cannot be resolved to a variable

ElementType cannot be resolved to a variable


二、异常原因:

没有引入这两个类

三、解决方法:

手动引入RetentionPolicy和ElementType这两个类

方法一:

import java.lang.annotation.*

方法二:

import java.lang.annotation.RetentionPolicy;

import java.lang.annotation.ElementType;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐