关于springboot:Spring-Boot学习三自动装配

1次阅读

共计 896 个字符,预计需要花费 3 分钟才能阅读完成。

@SpringBootApplication

// 设置以后注解能够标记在哪里
@Target(ElementType.TYPE)     
    
// 当注解标注的类编译以什么形式保留 RUNTIME 会被 JVM 加载        
@Retention(RetentionPolicy.RUNTIME)    
    
//java doc 会生成注解信息
@Documented            
    
// 是否会被继承                
@Inherited

// 标注在某个类上,示意这是一个 SPring Boot 的配置类
@SpringBootConfiguration

// 配置类上来标注这个注解
@Configuration

// 开启主动配置性能,会帮咱们主动去加载
@EnableAutoConfiguration

// 扫描包 相当于在 spring.xml 配置中 <context:comonent-scan> 
// 然而并没有指定 basepackage, 如果没有指定 spring 底层会主动扫描以后配置类所在的包
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
        @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })

//spring boot 对外提供的扩大类,能够供咱们去依照咱们的形式进行排除
TypeExcludeFilter

// 排除所有配置类并且是主动配置类外面的其中一个
AutoConfigurationExcludeFilter

@EnableAutoConfiguration

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited

// 将以后配置类所在的包保留在 BasePackages 的 Bean 中。供 Spring 外部应用
@AutoConfigurationPackage
@Import(AutoConfigurationImportSelector.class)
正文完
 0