原理初探
自动装配:
pom.xml
* spring-boot-dependencies 核心依赖在父工程中~**
里面有各种各样的jar包 不用写版本 因为都被管理了~ 直接调用即可
我们在写或者引入一些Springboot依赖的时候,不需要指定版本 因为有这些版本的仓库
<strong>spring-boot-starter-parent </strong></pre>
资源过滤都已经配置好了
如果插件下载失败就在这里操作 install 一下
启动器
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
如果把启动器依赖代码删了 程序就崩溃了!
- ** 启动器:就是Spring启动的场景**
- 比如 Spring-boot-starter-web 就会帮我们 自动导入 web的所有依赖
- Springboot会将所有的功能场景,变成一个个的启动器
主程序
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
注解
**@SpringBootConfiguration****: Springboot的配置**
**@Configuration:Springboot:配置类**
@Componnent :是一个Spring的组件
@EnableAutoConfiguration:自动配置
@AutoConfigurationPackage:自动配置包
@Import({Registrar.class}):导入选择器
@Import({AutoConfigurationImportSelector.class}):自动导入选择
这里是手动给容器导入组件! [图片上传失败...(image-35d51c-1660012502413)]