- spring-boot-dependencies(版本仓库):核心依赖在父工程中,父工程记录了所有第三方jar包的版本号
- 我们在引入或写入springboot依赖时,可以不要指定版本号,就是因为有版本仓库在。
启动器
可参考基本启动器44种
org.springframework.boot spring-boot-starter
- 启动器:简单来说就是springboot的使用场景
- 例如spring-boot-starter-web,他会帮助我们自动导入web环境所有的依赖
- springboot会将所有的功能场景,变成一个个的启动器
- 需要什么功能,就只需要找到对应的启动器即可。"strater-???"
主程序
//@SpringBootApplication:标注这个类是springboot的应用
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
//run:将springboot应用启动
SpringApplication.run(DemoApplication.class, args);
}
}
@SpringBootApplication注解:有以下几个父注解
@Target
@Documented
@Retention
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan
@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}
)}
)
起关键作用的两个注解
@SpringBootConfiguration :springboot的配置
@Configuration :spring配置类
@Component:说明这也是一个spring的组件
@EnableAutoConfiguration : 自动配置
@AutoConfigurationPackage :自动配置包
@Import({Registrar.class}) :自动配置“包注册”
@Import({AutoConfigurationImportSelector.class}) :自动配置导入选择
//获取所有的配置
List configurations = getCandidateConfigurations(annotationMetadata,attributes);



