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