使用 getAnnoations() 方法时,无法识别 Lombok @Getter 和 @Setter 注释

Lombok @Getter and @Setter annotations are not being recognised when getAnnoations() method is used

当 getAnnoations() 方法通过反射与变量一起使用时,无法识别 Lombok @Getter 和 @Setter 注释。关于如何使用反射测试这些注释是否存在有什么建议吗?

您无法在运行时检查这些注释,因为它们是 compile-time-only 注释 (RetentionPolicy.SOURCE),它们被编译器丢弃,因此不存在于已编译的 class 文件中。

无法在运行时查明 setter/getter 方法是由 lombok 生成的还是手动编写的。