0
我想定义一个自定义注释,并以下面的方式将其与Inject注释一起使用。如何访问注入bean中的注释值?豆内部自定义注释用法
注释定义,
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CustomAnnotation{
String name();
}
访问注释属性,
@Component
public class Processor {
Would like to know the value "abc" in constructor/post-constructor. How to access name method here ?
}
试验使用(该值“ABC”是用来加载各自的配置,使豆的行为适当地),
@Inject
@CustomAnnotation("abc")
Processor myProcessor;
public void test()
{
myProcessor.process(); // myProcessor will behave based on value "abc"
}