• 【SpringBoot】@SpringBootApplication


    注解定义

     1 @Target( {ElementType.TYPE})
     2 @Retention(RetentionPolicy.RUNTIME)
     3 @Documented
     4 @Inherited
     5 @SpringBootConfiguration
     6 @EnableAutoConfiguration
     7 @ComponentScan(excludeFilters = {
     8     @Filter(type = FilterType.CUSTOM, classes = {TypeExcludeFilter.class}),
     9     @Filter(type = FilterType.CUSTOM, classes = {AutoConfigurationExcludeFilter.class})
    10 })
    11 public @interface SpringBootApplication {
    12     @AliasFor(annotation = EnableAutoConfiguration.class) Class<?>[] exclude() default {};
    13 
    14     @AliasFor(annotation = EnableAutoConfiguration.class) String[] excludeName() default {};
    15 
    16     @AliasFor(annotation = ComponentScan.class, attribute = "basePackages") String[] scanBasePackages() default {};
    17 
    18     @AliasFor(annotation = ComponentScan.class,
    19         attribute = "basePackageClasses") Class<?>[] scanBasePackageClasses() default {};
    20 
    21     @AliasFor(annotation = ComponentScan.class,
    22         attribute = "nameGenerator") Class<? extends BeanNameGenerator> nameGenerator() default BeanNameGenerator.class;
    23 
    24     @AliasFor(annotation = Configuration.class) boolean proxyBeanMethods() default true;
    25 }

    @SpringBootConfiguration

     - @Configuration

    @EnableAutoConfiguration

      - @AutoConfigurationPackage

        -- @Import({Registrar.class})

    static class Registrar implements ImportBeanDefinitionRegistrar, DeterminableImports {
            Registrar() {
            }
    
            public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
                AutoConfigurationPackages.register(registry, (String[])(new AutoConfigurationPackages.PackageImports(metadata)).getPackageNames().toArray(new String[0]));
            }
    
            public Set<Object> determineImports(AnnotationMetadata metadata) {
                return Collections.singleton(new AutoConfigurationPackages.PackageImports(metadata));
            }
        }

      - @Import({AutoConfigurationImportSelector.class})

      - {String ENABLED_OVERRIDE_PROPERTY = "spring.boot.enableautoconfiguration";}

    public class AutoConfigurationImportSelector implements DeferredImportSelector, BeanClassLoaderAware, ResourceLoaderAware, BeanFactoryAware, EnvironmentAware, Ordered {
        private static final AutoConfigurationImportSelector.AutoConfigurationEntry EMPTY_ENTRY = new AutoConfigurationImportSelector.AutoConfigurationEntry();
        private static final String[] NO_IMPORTS = new String[0];
        private static final Log logger = LogFactory.getLog(AutoConfigurationImportSelector.class);
        private static final String PROPERTY_NAME_AUTOCONFIGURE_EXCLUDE = "spring.autoconfigure.exclude";
        private ConfigurableListableBeanFactory beanFactory;
        private Environment environment;
        private ClassLoader beanClassLoader;
        private ResourceLoader resourceLoader;
        private AutoConfigurationImportSelector.ConfigurationClassFilter configurationClassFilter;

    @ComponentScan

    
    
  • 相关阅读:
    Map与实体之间转换
    letsencrypt 免费SSL证书申请, 自动更新
    spring接收json格式的多个对象参数(变通法)
    controller函数中参数列表使用多个@RequestBody
    经典网页设计:30个新鲜出炉的扁平化网站设计《上篇》
    使用 iosOverlay.js 创建 iOS 风格的提示和通知
    字体大宝库:设计师必备的优秀免费英文字体
    RandomUser – 生成随机用户 JSON 数据的 API
    Salvattore:CSS 驱动的 jQuery Masonry 插件
    赞!jsPDF – 基于 HTML5 的强大 PDF 生成工具
  • 原文地址:https://www.cnblogs.com/clarino/p/15635302.html
Copyright © 2020-2023  润新知