更新時間:2021-06-22 16:31:11 來源:動力節點 瀏覽1543次
面試的時候經常會被問到,spring和springboot的區別。或者SpringMVC和Springboot的區別。其實這樣的問法就不是特別合適。因為spring、springboot、springmvc他們三個在spring體系中就不在同一個維度。
spring家族有很多項目,springboot、spring framework、spring cloud等。
我們常用的也就是,springboot、springcloud、springsecurity、springdata。常說的springmvc只是spring framework的特性之一。
1、內嵌Servlet容器,可以直接打成jar包,通過java-jar xx.jar運行項目。
2、提供starter pom系列,簡化maven的依賴加載,減少依賴沖突的發生。
3、支持自動化配置,如下圖。application.properties文件在引入springboot和未引入springboot時,是不一樣的。
實現的源碼:springboot回去判斷引入的jar包是否有spring.factories文件
EnableAutoConfiguration
Import({AutoConfigurationImportSelector.class})
protected List<String> getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) {
List<String> configurations = SpringFactoriesLoader.loadFactoryNames(this.getSpringFactoriesLoaderFactoryClass(), this.getBeanClassLoader());
Assert.notEmpty(configurations, "No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.");
return configurations;
}
總結:springboot 是 spring 家族的一個項目,他的目標是提高使用者的開發效率。
以上就是動力節點小編介紹的"Springboot與Spring的比較區別",希望對大家有幫助,更詳細的Java基礎教程可以登錄動力節點官網查看,學習中遇到問題,也可以請教在線咨詢,有專業老師隨時為您服務。
0基礎 0學費 15天面授
有基礎 直達就業
業余時間 高薪轉行
工作1~3年,加薪神器
工作3~5年,晉升架構
提交申請后,顧問老師會電話與您溝通安排學習