美文网首页
@Component派生性

@Component派生性

作者: 内卷星球 | 来源:发表于2019-07-06 19:45 被阅读0次

Spring核心部分提供了几种内建模式的注解,如@Component、@Service、@Repository、@Controller、@RestController以及@Configrution,但是Spring Framework并不限于这些内建模式注解,也可以自定义模式注解,Spring模式注解可理解为@Component"派生"注解

  • Spring Framework 2.x只支持单层的@Component派生
  • Spring Framework 3.0.0.RELEASE 后开始支持@Component,但是仅仅支持两层@Component派生(AnnotationAttributesReadingVisitor仅支持了两个for循环)
  • Spring Framework 4.0.0.RELEASE 后开始支持多层次的@Component派生(AnnotationAttributesReadingVisitor采用递归)

ClassPathBeanDefinitionScanner允许自定义类型过滤规则,因此,Dubbo的@Service在没有标注@Component的情况下,通过scanner.addIncludeFilter(newAnnotationTypeFilter(Service.class))的方式达到了识别@Service所标注类的目的,不过这种方式没有用到@Component的派生性

相关文章

网友评论

      本文标题:@Component派生性

      本文链接:https://www.haomeiwen.com/subject/ahsmhctx.html