crytis
V2EX  ›  Java

java-如何在运行的时候修改注解的参数值

  •  
  •   crytis · May 25, 2016 · 5914 views
    This topic created in 3648 days ago, the information mentioned may be changed or developed.

    比如 @Test(name="haha"),如何在程序运行中修改 haha 为别的值?

    5 replies    2016-05-26 15:24:18 +08:00
    qinxi
        1
    qinxi  
       May 26, 2016
    从反射中来,到反射中去..瞎猜
    twoyuan
        3
    twoyuan  
       May 26, 2016
    貌似真实代码和答案里有些出入, annotations 这个 map 现在在 class 中 annotationData 里了,改过的代码贴一下:

    https://gist.github.com/twiceyuan/b8b4d952d6fd641e98f68f1e9d327988
    crytis
        4
    crytis  
    OP
       May 26, 2016
    @twoyuan 多谢。用中文搜的没搜到。。
    看了一会,没太看明白。慢慢研究下。
    另外问一下, spring 容器中的 bean 上的注解可以用这个方法改吗
    twoyuan
        5
    twoyuan  
       May 26, 2016
    @crytis 不太清楚了,我不是做 Java 后端的,对 Spring 不熟悉
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1388 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 140ms · UTC 17:12 · PVG 01:12 · LAX 10:12 · JFK 13:12
    ♥ Do have faith in what you're doing.