Home  >  Q&A  >  body text

java - 注解上的属性可以传递吗?

Spring里@Component有一个value属性可以设置,MyComponentvalue可以传给@Component吗?

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Component()
public @interface MyComponent {
    String value() default "";
}
巴扎黑巴扎黑2744 days ago477

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 10:49:16

    This is more troublesome. It can be implemented through reflection.

    reply
    0
  • PHPz

    PHPz2017-04-18 10:49:16

    Annotations don’t seem to support inheritance

    reply
    0
  • Cancelreply