@ImportSelector、@Import、ImportResource工作原理分析

@importSelector

  • 接口定义

public interface ImportSelector {

    /**
     * Select and return the names of which class(es) should be imported based on
     * the {@link AnnotationMetadata} of the importing @{@link Configuration} class.
     */
    String[] selectImports(AnnotationMetadata importingClassMetadata);

}
  • 实现线索

  • 具体代码实现:

@Import和@ImportResource

  • ConfigurationClassParser

Last updated

Was this helpful?