spring注册bean

206 阅读1分钟
  1. @ComponentScans及@ComponentScan 配置扫描的包路径,以及指定扫描的时候包含哪些组件或者排除哪些组件(可以扩展被spring托管Bean的规则),规则如下: org.springframework.context.annotation.FilterType
    1. //FilterType.ANNOTATION:类是否有注解修饰
    2. //FilterType.ASSIGNABLE_TYPE:按照给定的类型;

    3. //FilterType.ASPECTJ:使用ASPECTJ表达式
    4. //FilterType.REGEX:类名是否满足正则表达式
    5. //FilterType.CUSTOM:使用自定义规org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isCandidateComponent(MetadataReader),先判断excludeFilters,再判断includeFilters。
  2. @Bean
  3. @Import

  4. FactoryBean