springboot基础(随笔)


<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,给容器中导入一个组件


 
ZGC说:有什么能比不给牛吃草,还挤牛奶更快乐的事情呢?
原文地址:https://www.cnblogs.com/lovestart/p/11216014.html