网站建设电话销售模版,入侵wordpress,wordpress改变主题页脚,软件开发工程师是什么职业本系列文章为【狂神说 Java 】视频的课堂笔记#xff0c;若有需要可配套视频学习。 1.1 pom.xml
(1) 父工程#xff08; spring-boot-starter-parent #xff09;
核心依赖#xff0c;静态资源过滤等配置。编写或导入 springboot 依赖时不需要指定版本号#xff0c;继承… 本系列文章为【狂神说 Java 】视频的课堂笔记若有需要可配套视频学习。 1.1 pom.xml
(1) 父工程 spring-boot-starter-parent
核心依赖静态资源过滤等配置。编写或导入 springboot 依赖时不需要指定版本号继承父工程版本。
(2) 启动器 spring-boot-starter springboot 的启动场景功能场景。 添加某功能对应的启动器依赖即可使用此功能。 springboot 的依赖前缀 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId
/dependency1.2 主程序
SpringBootApplication
public class HelloApplication {public static void main(String[] args) {SpringApplication.run(HelloApplication.class, args);}
}1.2.1 注解 SpringBootApplication SpringBootConfiguration SpringBoot 配置类 EnableAutoConfiguration 自动装配 自动装配流程 springboot 启动时从 spring.factories 获取目标类组件的全限定名将其添加到容器。 配置仓库 spring.factories 中的所有配置类含 ConditionalOnxxx 注解只有满足此注解的所有条件此配置才会生效。 结论 springboot 的自动配置是在启动时扫描并加载的。导入对应的启动器 starter 自动装配就会生效。
1.2.2 main 方法
(1) SpringApplication 类 判断此应用是普通 Java 项目还是 Web 项目。 查找并加载所有可用的初始化器设置到 initializers 中。 查找所有应用程序监听器设置到 listeners 中。 推断并设置 main 方法的定义类找到主类。 查看类构造器。 /*** 创建一个新的 SpringApplication 实例用于加载应用程序上下文该实例可以在调用 run 方法* 前自定义。* param resourceLoader 资源加载器* param primarySources bean 源* see #run(Class, String[])* see #setSources(Set)*/
SuppressWarnings({ unchecked, rawtypes })
public SpringApplication(ResourceLoader resourceLoader, Class?... primarySources) {this.resourceLoader resourceLoader;Assert.notNull(primarySources, PrimarySources must not be null);this.primarySources new LinkedHashSet(Arrays.asList(primarySources));this.webApplicationType WebApplicationType.deduceFromClasspath();this.bootstrapRegistryInitializers getBootstrapRegistryInitializersFromSpringFactories();setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));this.mainApplicationClass deduceMainApplicationClass();
}(2) run() 方法 启动应用监听器、获取装配环境参数等。 执行流程