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

一、异常现象:

自定义注解时,

@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;

 

posted @ 2017-09-20 15:22  shirayner  阅读(1768)  评论(0编辑  收藏  举报