SpringBoot框架简单入门

    技术2024-03-15  94

    SpringBoot框架简单入门

    1.关于SpringBoot配置说明

    parent标签作用:

    - 管理所有被springBoot整合之后的jar包的版本定义

    springBoot特点:

    - 开箱即用 引入jar局可以用响应的功能

    其中定义了当前springBoot2.3.1所有的依赖版本号的子集

    springBoot项目路径

    负责打包 更新maven操作相关的配置

    2.SpringBoot主启动类说明

    FAQ分析:

    为什么指定了主启动类的方式 Tomcat服务器可以自动的运行,并且SpringMVC的框架可以自动的配置? 程序执行的过程:

    1.利用main方法执行springBoot启动程序 2.程序加载@SpringBootApplication

    @Target(ElementType.Type) 当前注解对类有效@Retention(RetentionPolicy.RunTime)在运行期该注解有效@Documented 相关文档信息@Inherited 可以被继承 以上注解为元注解@SpringBootConfiguration SpringBoot的主启动类就是一个配置类@EnableAutoConfiguration 实现开箱即用的功能,下图为该注解源码 @AutoConfigurationPackage 定义包扫描的路径信息 主启动类的包路径,写代码至少同步或子包中@Import(AutoConfigurationImportSelector.class) 实现了开箱即用的功能 总结:SpringBoot 中选择器的配置,扫描pom.xml文件中的jar包文件,之后将jar包文件中的配置予以执行. public class AutoConfigurationImportSelector implements DeferredImportSelector, BeanClassLoaderAware, ResourceLoaderAware, BeanFactoryAware, EnvironmentAware, Ordered { 说明:Aware是Spring框架从项目的启动到项目的销毁的各个时期的接口

    加载第三方的类信息 @ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class), * @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })

    Processed: 0.020, SQL: 9