1.starter的作用
starter一句話來描述就是開發中我們引入了相關場景的starter,這個場景中所有的相關依賴都引入進來了,比如我們做web開發引入了:
<!--web插件-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
該starter將匯入與web開發相關的所有包,如下:

分析依賴樹如下:

可以看到我們就引入了一個spring-boot-starter-web,他幫我們引入了spring-webmvc,spring-web開發模塊,還引入了spring-boot-starter-tomcat場景,spring-boot-starter-json場景,這些場景下面又引入了一大堆相關的包,
總結:
starter包含許多依賴項,這些依賴項可以快速啟動和運行一個專案,匯入starter獲得所需的所有Spring和相關技術的一站式服務,而不必搜索示例代碼和復制粘貼大量依賴描述符,
2.官方提供的starter
在開發中我們經常會用到spring-boot-starter-xxx ,這xxx可以是web,也就是上述中的spring-boot-starter-web,該場景是用作web開發,
也就是說xxx是某種開發場景,
我們只要引入starter,這個場景的所有常規需要的依賴我們都自動引入,
SpringBoot支持的所有場景如下:
https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-starter
3.第三方starter
第三方啟動程式不應該從spring-boot開始,因為它是為官方spring-boot工件保留的,相反,第三方啟動程式通常以專案名稱開頭,例如,名為thirdpartyproject的第三方啟動程式專案通常被命名為thirdpartyproject-spring-boot-starter,
也就是說:xxx-spring-boot-starter是第三方為我們提供的簡化開發的場景啟動器,
4.所有場景啟動器最基本的依賴
所有場景啟動器最基本的依賴就是spring-boot-starter:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.4.1</version>
<scope>compile</scope>
</dependency>
這個依賴也就是SpringBoot自動配置的核心依賴,
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/241988.html
標籤:其他
上一篇:實驗八 查找演算法比較
下一篇:VUE面試題系列02,前端面試題
