0
私はカスタムアノテーションを定義し、それを以下の方法でInjectアノテーションと共に使用したいと思います。注入されたbean内の注釈値にアクセスするには?カスタムアノテーションの使用
注釈定義、豆、
@Component
public class Processor {
Would like to know the value "abc" in constructor/post-constructor. How to access name method here ?
}
テストの使用( "ABC" がそれぞれ設定をロードし、Beanが適切に動作するために使用される値)内部
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CustomAnnotation{
String name();
}
アクセス注釈特性、
@Inject
@CustomAnnotation("abc")
Processor myProcessor;
public void test()
{
myProcessor.process(); // myProcessor will behave based on value "abc"
}