使用GetAnnoations()方法时,未识别Lombok @getter和@setter注释

发布于 2025-01-24 04:38:22 字数 89 浏览 3 评论 0原文

Lombok @getter和@setter注释在GetAnnoations()方法中都未被识别,并通过反射为变量。关于如何使用反射测试是否存在这些注释的任何建议?

Lombok @Getter and @Setter annotations are not being recognised when getAnnoations() method is used with a variable by reflection. Any suggestions on how to test if these annoations are present using reflection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

镜花水月 2025-01-31 04:38:22

您无法在运行时检查这些注释,因为它们是仅编译时间的注释(retention-policy.source),这些注释由编译器丢弃,因此在编译的类文件中不存在。

在运行时找不到找出六个二阶/Getter方法是由Lombok生成还是手动书写。

You cannot check for those annotations during runtime, as they are compile-time-only annotations (RetentionPolicy.SOURCE) which are discarded by the compiler and thus not present in the compiled class files.

There is no way to find out during runtime whether a setter/getter method was generated by lombok or written manually.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文