Spring Boot Tutorial
Spring Boot - Software Setup and Configuration (STS/Eclipse/IntelliJ)
Prerequisite (Spring Core Concepts)
Spring Boot Core
Spring Boot with REST API
Spring Boot with Database and Data JPA
Spring Boot with Kafka
Spring Boot with AOP
In the Spring Boot ecosystem, "starters" are a set of convenient dependency descriptors that allow developers to simplify their build configuration. Starters encapsulate common dependencies into single references. Let's look into the differences between spring-boot-starter-web
and spring-boot-starter-tomcat
.
Purpose: This starter is used to build web applications, including RESTful APIs, using Spring MVC. It provides tools for creating web applications that can handle HTTP requests and responses.
Dependencies: It bundles a variety of dependencies, which include:
Usage: When you want to create a Spring-based web application or RESTful service, you would include this starter. By including this starter, you get everything you need to quickly set up and run a web-based application.
Purpose: This starter provides an embedded Tomcat servlet container as the default. It's specifically focused on Tomcat as the application server.
Dependencies: It primarily bundles:
Usage: In most cases, you don't need to directly include this starter, as it's a transitive dependency of spring-boot-starter-web
. However, in scenarios where you want to customize the embedded Tomcat version or if you're creating a non-web application but want an embedded Tomcat for some reason, you might add it explicitly.
spring-boot-starter-web
is a broader starter that provides everything you need to create a web application, including the embedded Tomcat.spring-boot-starter-tomcat
, on the other hand, is more focused, only providing Tomcat-specific dependencies for embedding Tomcat in an application.When you add spring-boot-starter-web
to your project, you're implicitly getting spring-boot-starter-tomcat
because the former includes the latter. However, there can be scenarios where you might want to exclude the default Tomcat (e.g., when you want to use Jetty or Undertow as your embedded server) or include it explicitly for customization.