Table of contents
1.
Introduction
2.
What is a spring boot starter web?
3.
Spring boot embedded web server
4.
Jetty server
5.
Undertow server
6.
What makes spring boot starter web different from spring boot starter tomcat?
7.
FAQs
8.
Key takeaway
Last Updated: Oct 24, 2024

Spring Boot Starter Web

Author Ranjul Arumadi
2 upvotes
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Spring boot is an open-source Java-based framework that helps create standalone applications that can run independently. Running these websites does not require an external web server. Spring boot was developed to let developers spend more time on code and less time on dependencies. The starter gives all dependencies under a single name. Spring boot starter web decreases the configuration time for developers. It also takes away the burden of the need of developers to remember the name and version of the dependencies.

What is a spring boot starter web?

It helps create standalone applications that can be run independently without requiring an external web server. It increases the developers' productivity by letting them spend more time coding and taking away the burden of remembering the name and dealing with dependencies.

 

The important feature of the spring boot starter web is it is compatible with web development and supports autoconfiguration.

 

For making web applications, the following dependency has to be added in the pom.xml file.

<dependency>  
<groupId>org.springframework.boot</groupId>  
<artifactId>spring-boot-starter-web</artifactId>  
<version>2.2.2.RELEASE</version>  
</dependency> 
You can also try this code with Online Java Compiler
Run Code

 

The default embedded servers in the starter of spring web are Spring MVC, REST, and Tomcat

 

Spring boot requirements are dispatcher servlet, error page, web JARs for managing the static dependencies, and embedded servlet container.

You can explore these features in depth by enrolling in our Spring Boot Course, which covers everything you need to know to master this framework. 

Spring boot embedded web server

Every application in spring boot has an embedded server. The server is embedded as a part of the deployable application. The advantage of the embedded server is that it does not require a pre-installed server. Instead, the embedded web server has a default embedded server called the Tomcat. Other embedded systems supported apart from default are jetty server and undertow server. The spring boot starter includes Tomcat and spring boot starter for application in the servlet stack. We can also use a spring boot starter jetty or spring boot starter undertow.

Jetty server

Jetty server is an HTTP server. The servlet container can serve static and dynamic content, mainly used where there is a requirement of communication between one machine to another. Customization of the jetty server can be done using an application.properties file.

 

To avoid conflict between the servers while using the jetty server, first, make sure that the default server Tomcat is excluded from the spring boot starter web. We need to add the spring-boot-starter-jetty dependency in our pom.xml file. We can find the updated pom.xml file below.

 

<dependency>  
<groupId>org.springframework.boot</groupId>  
<artifactId>spring-boot-starter-web</artifactId>  
<exclusions>  
<exclusion>  
<groupId>org.springframework.boot</groupId>  
<artifactId>spring-boot-starter-tomcat</artifactId>  
</exclusion>  
</exclusions>  
</dependency>  
<dependency>  
<groupId>org.springframework.boot</groupId>  
<artifactId>spring-boot-starter-jetty</artifactId>  
</dependency>
You can also try this code with Online Java Compiler
Run Code

Undertow server

The Undertow server is an embedded web similar to a jetty server. It is written in Java. Unlike other embedded servers,  the undertow server supports HTTP/2, HTTP upgrade support, WebSocket support, etc. It is also flexible. Customization of the undertow server can be done using an application.properties file.

 

To avoid conflict between the servers while using the undertow server, first, make sure that the default server Tomcat is excluded from the spring boot starter web. We can find the updated pom.xml file below.

 

<dependency>  
<groupId>org.springframework.boot</groupId>  
<artifactId>spring-boot-starter-web</artifactId>  
<exclusions>  
<exclusion>  
<groupId>org.springframework.boot</groupId>  
<artifactId>spring-boot-starter-tomcat</artifactId>  
</exclusion>  
</exclusions>  
</dependency>  
<dependency>  
<groupId>org.springframework.boot</groupId>  
<artifactId>spring-boot-starter-undertow</artifactId>  
</dependency>  
You can also try this code with Online Java Compiler
Run Code

What makes spring boot starter web different from spring boot starter tomcat?

Spring boot starter tomcat is included in spring web dependencies. The spring web dependencies are present in the spring boot starter web. The spring boot starter web contains spring boot starter, Jackson, spring core, spring MVC, spring boot starter tomcat.

Core, el, logging, and WebSocket are present in the spring boot starter tomcat.

 

We can use Spring MVC without an embedded tomcat server. To do this, we have to exclude the Tomcat server using the <extension>

 

The dependencies present in the starter tomcat are:

 

<dependency>  
<groupId>org.apache.tomcat.embed</groupId>  
<artifactId>tomcat-embed-core</artifactId>  
<version>8.5.23</version>  
<scope>compile</scope>  
</dependency>  
<dependency>  
<groupId>org.apache.tomcat.embed</groupId>  
<artifactId>tomcat-embed-el</artifactId>  
<version>8.5.23</version>  
<scope>compile</scope>  
</dependency>  
<dependency>  
<groupId>org.apache.tomcat.embed</groupId>  
<artifactId>tomcat-embed-websocket</artifactId>  
<version>8.5.23</version>  
<scope>compile</scope>  
</dependency> 
You can also try this code with Online Java Compiler
Run Code

FAQs

  1. What are the advantages of spring boot?
    Spring boot helps create standalone applications without using an external web server. It allows us to use embedded servers such as Tomcat, undertow, or jetty.
     
  2. What are the important features of using a spring boot?
    Some of the important spring boot features are starter dependency, auto-configuration, and spring initializer.
     
  3. What is a spring boot admin?
    Spring Boot Admin is a web application. It is used for managing and monitoring Spring Boot applications.

Key takeaway

Spring boot helps to create standalone applications. They do not require an external web server. They have an embedded server. The server is embedded as a part of the deployable application. The default embedded server is called Tomcat. Other embedded systems supported apart from default are the Jetty server and the Undertow server. We have seen what a spring boot starter web is. We have looked at the different server types like the Spring boot embedded server, the Undertow server. We have also looked at how the Spring boot web server is different from the Tomcat server.

Recommended Readings:

 

Live masterclass