如何使用反射在运行时改变注释值? [英] How to change annotation value at runtime using reflection?

查看:128
本文介绍了如何使用反射在运行时改变注释值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是注释。

@Before(value="execution(* class.method(**)")

使用Java反射我可以改变单一的价值诠释的价值?

Can i change the value of single value annotation using java reflection?

请建议。

推荐答案

你在找什么的描述可以在这里找到 。但要警惕使用这种方法,它的一些告诫的也有所说明。

The description of what you are looking for can be found here. But be wary about using such approach, some of the caveats of it are also described.

此外,注释的保留策略为运行,此

Also, the retention policy of the annotation has to be runtime, for this.

在你的问题评论的链接导致了后看起来的就像你问什么,但不同的是,它是关于一个JPA / Hibernate的注释在运行时间,其中你得到的代理的类类。

The link in the comment to your question leads to a post that looks like something you are asking about, but the difference is that it is about a JPA/Hibernate annotation where in the run-time you get a proxy class to your class.

这篇关于如何使用反射在运行时改变注释值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆