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;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM