SpringBoot Pom文件依賴及Starter啟動器詳細(xì)介紹
Pom文件的依賴
我們進(jìn)入POM文件,首先是看到的是Pom文件中的parent
parent是Spring Boot的框架版本控制中心
<!-- 導(dǎo)入springboot版本和框架依賴 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.6.3</version> <relativePath></relativePath> </parent>
點進(jìn)去看一下parent是如何控制版本的。點進(jìn)去之后,發(fā)現(xiàn)它也有一個父工程
它的父工程為spring-boot-dependencies,看到名字應(yīng)該想到,是springboot的依賴。同時還有其他東西。再點進(jìn)去,看到里面有<dependencyManagement>
,管理各種依賴的版本。
到這里就差不多理解了parent是如何控制版本的。
我們創(chuàng)建的springboot
工程是spring-boot-start-parent
的子工程,spring-boot-starter-parent
是spring-boot-denpendencies
的子工程,父工程通過dependencyManagement
控制了各種依賴的版本。所以當(dāng)子工程導(dǎo)入依賴時,可以不寫版本,自動使用父工程規(guī)定的版本,以此來進(jìn)行版本的控制。
spring-boot場景啟動器
starter:spring-boot場景啟動器
我們以web啟動器為例:
<!-- 導(dǎo)入動態(tài)web場景啟動器 --> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
我們還是點進(jìn)去看到spring-boot-starter-web的內(nèi)容:
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>2.6.3</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-json</artifactId> <version>2.6.3</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <version>2.6.3</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.3.15</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.3.15</version> <scope>compile</scope> </dependency> </dependencies>
可以看到里面集成了web開發(fā)的其他依賴,也就是說通過添加Spring-boot-starter-web
依賴,它就導(dǎo)入了web環(huán)境所有的依賴,只需導(dǎo)入starter,可自動導(dǎo)入web模塊正常運行所依賴的組件。其他的starter也是一樣的。
springboot出廠默認(rèn)就寫好了很多starter,如:
spring-boot-starter-activemq,spring-boot-starter-aop,spring-boot-starter-data-redis,spring-boot-starter-data-solr等
重要提示:Spring Boot將所有的絕大部分框架整合場景都進(jìn)行了抽取,做成一個個的starters(啟動器),只需要在項目里面引入這些starter相關(guān)整合所需的依賴都會導(dǎo)入進(jìn)來。
到此這篇關(guān)于SpringBoot Pom文件依賴及Starter啟動器詳細(xì)介紹的文章就介紹到這了,更多相關(guān)SpringBoot Pom文件依賴內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
在Spring Boot中使用Spark Streaming進(jìn)行實時數(shù)據(jù)處理和流式計算的步驟
這篇文章主要介紹了在Spring Boot中使用Spark Streaming進(jìn)行實時數(shù)據(jù)處理和流式計算,通過本文的介紹,我們了解了在Spring Boot中使用Spark Streaming進(jìn)行實時數(shù)據(jù)處理和流式計算的詳細(xì)步驟,需要的朋友可以參考下2024-03-03Spring boot 集成 Druid 數(shù)據(jù)源過程詳解
這篇文章主要介紹了Spring boot 集成 Druid 數(shù)據(jù)源過程詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-08-08IntelliJ IDEA2020.2.2創(chuàng)建Servlet方法及404問題
這篇文章主要介紹了IntelliJ IDEA2020.2.2創(chuàng)建Servlet方法及404問題,這里小編使用的2020.2.2企業(yè)破解版本,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-09-09解決springboot自定義配置Boolean屬性不能生效的問題
這篇文章主要介紹了解決springboot自定義配置Boolean屬性不能生效的問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-05-05