spring-boot
tomcat
spring-boot-starter-web
spring-boot-starter-tomcat
java

spring-boot-starter-tomcat vs spring-boot-starter-web

Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms

Spring Boot is known for its ability to simplify the development process of Java web applications by providing a comprehensive suite of features and integrations. Two of the popular starters in the Spring Boot ecosystem are `spring-boot-starter-tomcat` and `spring-boot-starter-web`. Understanding the distinctions between these two can help developers make informed decisions based on the requirements of their project.

Overview of Spring Boot Starters

Spring Boot starters are a way to easily include dependencies needed for a particular functionality in your application. When you include a starter in your `pom.xml` (for Maven) or `build.gradle` (for Gradle), it automatically pulls in a set of transitive dependencies that provide the necessary services.

spring-boot-starter-web

Description

`spring-boot-starter-web` is a starter for building web applications, including RESTful services, using Spring MVC. By default, it uses Tomcat as the embedded container but can be swapped to other containers like Jetty or Undertow if required.

Key Components

  • Spring MVC: Facilitates the development of web applications with the Model-View-Controller design pattern.
  • Embedded Tomcat (Default): Provides HTTP server capabilities.
  • Jackson: For JSON binding.
  • Validation and Binding: Support for validating inputs and performing data binding.
  • Spring Web: Core capabilities for web applications.

Usage

To use `spring-boot-starter-web` in your Spring Boot project, add the following to your `pom.xml`:

  • Embedded Tomcat: The core library for the Tomcat server.
  • Jasper: JSP support, especially useful if you're using JSP as a view technology.
  • Selective Dependency: Allows using Tomcat alone without Spring MVC.
  • Project Requirements: Assess if you need a comprehensive web framework (`spring-boot-starter-web`) or just the embedded server capabilities (`spring-boot-starter-tomcat`).
  • Customization: If you require customizations specific to Tomcat, such as altering the thread pool, access logs, or specific connector settings, using `spring-boot-starter-tomcat` directly may be beneficial.
  • Dependency Management: Using `spring-boot-starter-web` ensures that the common dependencies for a web application are all included, simplifying dependency management.

Course
Intermediate
27 lessons
14 hours
OOD Fundamentals

Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.

View the course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms