54 個官方 Spring Boot Starters 出爐!別再重復造輪子了…….


在之前的文章,棧長介紹了 Spring Boot Starters,不清楚的可以點擊鏈接進去看下。

前段時間 Spring Boot 2.4.0 也發布了,本文棧長再詳細總結下最新的 Spring Boot 2.4.0 官方的 Starters 都有哪些。

Spring Boot 基本介紹這里就不介紹了,關注公眾號Java技術棧回復關鍵字 "boot",可以閱讀我寫的幾十篇往期實戰文章。這個 Spring Boot 實戰倉庫,也歡迎 Star 關注學習:

https://github.com/javastacks/spring-boot-best-practice

Spring Boot starters

1、application starters

你還在手寫配置引入框架?建議看看這個表格。

這一個表格是 Spring Boot 所有應用程序級的 Starters,一起來看都有哪些。

Starter 名稱 Starter 描述
spring-boot-starter 核心 Starter,包括自動配置、日志及 YAML 支持等
spring-boot-starter-activemq 集成 Apache ActiveMQ,基於 JMS 的消息隊列
spring-boot-starter-artemis 集成 Apache Artemis,基於 JMS 的消息隊列
spring-boot-starter-amqp 集成 Spring AMQP 和 Rabbit MQ 的消息隊列
spring-boot-starter-aop 集成 Spring AOP 和 AspectJ 面向切面編程
spring-boot-starter-batch 集成 Spring Batch(批處理)
spring-boot-starter-cache 集成 Spring Cache(緩存)
spring-boot-starter-data-cassandra 集成 Cassandra(分布式數據庫) 和 Spring Data Cassandra
spring-boot-starter-data-cassandra-reactive 集成 Cassandra(分布式數據庫) 和 Spring Data Cassandra Reactive
spring-boot-starter-data-couchbase 集成 Couchbase(文檔型數據庫) 和 Spring Data Couchbase
spring-boot-starter-data-couchbase-reactive 集成 Couchbase(文檔型數據庫) 和 Spring Data Couchbase Reactive
spring-boot-starter-data-elasticsearch 集成 Elasticsearch(搜索引擎)和 Spring Data Elasticsearch
spring-boot-starter-data-solr 集成 Apache Solr(搜索引擎)結合 Spring Data Solr
spring-boot-starter-data-jdbc 集成 Spring Data JDBC
spring-boot-starter-data-jpa 集成 Spring Data JPA 結合 Hibernate
spring-boot-starter-data-ldap 集成 Spring Data LDAP
spring-boot-starter-data-mongodb 集成 MongoDB(文檔型數據庫)和 Spring Data MongoDB
spring-boot-starter-data-mongodb-reactive 集成 MongoDB(文檔型數據庫)和 Spring Data MongoDB Reactive
spring-boot-starter-data-neo4j 集成 Neo4j(圖形數據庫)和 Spring Data Neo4j
spring-boot-starter-data-r2dbc 集成 Spring Data R2DBC
spring-boot-starter-data-redis 集成 Redis(內存數據庫)結合 Spring Data Redis 和 Lettuce 客戶端
spring-boot-starter-data-redis-reactive 集成 Redis(內存數據庫)結合 Spring Data Redis reactive 和 Lettuce 客戶端
spring-boot-starter-data-rest 集成 Spring Data REST 暴露 Spring Data repositories 輸出 REST 資源
spring-boot-starter-thymeleaf 集成 Thymeleaf 視圖構建 MVC web 應用
spring-boot-starter-freemarker 集成 FreeMarker 視圖構建 MVC web 應用
spring-boot-starter-groovy-templates 集成 Groovy 模板視圖構建 MVC web 應用
spring-boot-starter-hateoas 集成 Spring MVC 和 Spring HATEOAS 構建超媒體 RESTful Web 應用程序
spring-boot-starter-integration 集成 Spring Integration
spring-boot-starter-jdbc 集成 JDBC 結合 HikariCP 連接池
spring-boot-starter-jersey 集成 JAX-RS 和 Jersey 構建 RESTful web 應用,是 spring-boot-starter-web 的一個替代 Starter
spring-boot-starter-jooq 集成 jOOQ 訪問 SQL 數據庫,是 spring-boot-starter-data-jpa 或者 spring-boot-starter-jdbc 的替代 Starter
spring-boot-starter-json 用於讀寫 JSON
spring-boot-starter-jta-atomikos 集成 Atomikos 實現 JTA 事務
spring-boot-starter-jta-bitronix 集成 Bitronix 實現 JTA 事務( 從 2.3.0 開始標識為 Deprecated
spring-boot-starter-mail 集成 Java Mail 和 Spring 框架的郵件發送功能
spring-boot-starter-mustache 集成 Mustache 視圖構建 web 應用
spring-boot-starter-security 集成 Spring Security
spring-boot-starter-oauth2-client 集成 Spring Security’s OAuth2/OpenID 連接客戶端功能
spring-boot-starter-oauth2-resource-server 集成 Spring Security’s OAuth2 資源服務器功能
spring-boot-starter-quartz 集成 Quartz 任務調度
spring-boot-starter-rsocket 構建 RSocket 客戶端和服務端
spring-boot-starter-test 集成 JUnit Jupiter, Hamcrest 和 Mockito 測試 Spring Boot 應用和類庫
spring-boot-starter-validation 集成 Java Bean Validation 結合 Hibernate Validator
spring-boot-starter-web 集成 Spring MVC 構建 RESTful web 應用,使用 Tomcat 作為默認內嵌容器
spring-boot-starter-web-services 集成 Spring Web Services
spring-boot-starter-webflux 集成 Spring Reactive Web 構建 WebFlux 應用
spring-boot-starter-websocket 集成 Spring WebSocket 構建 WebSocket 應用

用到哪個技術就引用哪個技術的 Starter,Spring Boot 助你快速集成,別再手寫配置了。

2、production starters

除了上面的應用程序級 starters,還有下面的生產級 Starters 能被用於線上/生產功能:

Starter 名稱 Starter 描述
spring-boot-starter-actuator 集成 Spring Boot Actuator,提供生產功能以幫助監控和管理應用程序

這個意味着和任何技術、任何業務沒關系,只要用了 Spring Boot 框架,上了生產環境就能使用,也不是只有生產才能使用,只是在生產環境使用更能體驗它的意義。

3、technical starters

除了應用程序和生產 Starters,Spring Boot 還包括下面的技術類 Starters,用於幫助你排除或者替換指定的框架或技術:

Starter 名稱 Starter 描述
spring-boot-starter-jetty 集成 Jetty 作為內嵌的 servlet 容器,可用於替代 spring-boot-starter-tomcat
spring-boot-starter-log4j2 集成 Log4j2 日志框架,可用於替代 spring-boot-starter-logging
spring-boot-starter-logging 集成 Logback 日志框架,這個也是默認的日志 Starter
spring-boot-starter-reactor-netty 集成 Netty 作為內嵌的響應式 HTTP 服務器
spring-boot-starter-tomcat 集成 Tomcat 作為內嵌的 servlet 容器,這也是默認的 servlet 容器 starter 被集成 spring-boot-starter-web 里面
spring-boot-starter-undertow 集成 Undertow 作為內嵌的 servlet 容器,可用於替代 spring-boot-starter-tomcat

這個表格的技術也很熟悉了,Spring Boot 默認內嵌 Servlet 容器為 Tomcat,如果你想換成 Jetty、Undertow 或者其他容器,又或者你想換成其他的日志框架,都在這個表格里,怎么換?點擊這里參考我之前寫的這篇教程。

最新請參考:

https://docs.spring.io/spring-boot/docs/

結語

本文一共收集了 54 個 Spring Boot 官方的 Starter,參考來源於 Spring Boot 2.4.0,不限於這 54 個,隨着 Spring Boot 版本的不斷升級,后續可能會增加更多的 Starter,當然也有少數 Starter 可能會得到刪除。

官方自帶的可以直接拿來用,大家看看,就沒有必要重復造輪子了。

如果 Spring Boot 官方沒有自帶的 Starter,一般第三方的框架也都會提供自制的 Spring Boot Starter,如:Dubbo、Zookeeper 等,這樣只要幾個依賴,幾行配置參數就能輕松實現集成。后面棧長再整理一篇常用的第三方的 Starters,關注公眾號Java技術棧第一時間推送。

當然,除了第三方的 Starter,使用 Spring Boot 的公司一般也會有私有定制的 Starter,可以用於在公司內部各業務部門快速集成使用,而不用各自造輪子。

除了會使用 Spring Boot Starter,了解它的原理也非常有必要,因為你的上司隨時都會讓你寫一個!

好了,今天的分享就到這了,后續有大版本更新,官方 Starters 調整比較大的話,后續棧長再繼續更新本文,關注公眾號Java技術棧第一時間推送。

如果有幫助,點個在看鼓勵一下哦!也歡迎分享轉發給更多有需要的朋友~

版權申明:本文系公眾號 "Java技術棧" 原創,原創實屬不易,轉載、引用本文內容請注明出處,禁止抄襲、洗稿,請自重,尊重他人勞動成果和知識產權。

近期熱文推薦:

1.Java 15 正式發布, 14 個新特性,刷新你的認知!!

2.終於靠開源項目弄到 IntelliJ IDEA 激活碼了,真香!

3.我用 Java 8 寫了一段邏輯,同事直呼看不懂,你試試看。。

4.吊打 Tomcat ,Undertow 性能很炸!!

5.《Java開發手冊(嵩山版)》最新發布,速速下載!

覺得不錯,別忘了隨手點贊+轉發哦!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM