一、异常现象:

自定义注解时,

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

 

相关文章:

  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-09-23
  • 2021-05-26
猜你喜欢
  • 2021-06-13
  • 2021-09-01
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
相关资源
相似解决方案