首页 > 技术文章 > springboot基础(随笔)

lovestart 2019-07-19 22:19 原文


<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.1.6.RELEASE</version> <relativePath>../../spring-boot-dependencies</relativePath> </parent>

springboot 的版本管理器

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-*</artifactId>
</dependency>

springboot的启动器,可以帮助导入相关的依赖

 

@SpringBootApplication //springboot的主程序注解
//该注解又由以下注解构成
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication {
@SpringBootConfiguration //这是一个springboot的配置类
@configuration //配置类也是容器中的一个组件

@EnableAutoConfiguration //开启自动配置
//该注解内有以下注解

@AutoConfigurationPackage

//将主配置类下的所有的包都扫描到容器中
@Import(AutoConfigurationImportSelector.
class)
@AutoConfigurationPackage //自动配置包
  @Import(AutoConfigurationPackages.Registrar.class)
  spring中底层的注解@Import,给容器中导入一个组件


 

 

 

推荐阅读