Difference Between Spring Boot Starter Web and Spring Boot Starter Tomcat
Last Updated : 11 Mar, 2022
Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. Spring Boot is a microservice-based framework and making a production-ready application in it takes very little time. Following are some of the features of Spring Boot:
- It allows avoiding heavy configuration of XML which is present in spring
- It provides easy maintenance and creation of REST endpoints
- It includes embedded Tomcat-server
- Deployment is very easy, war and jar files can be easily deployed in the tomcat server
Spring Boot Starter Web
It is mainly used for building web applications that include RESTful applications using Spring MVC. It uses Tomcat as the default embedded container. It has two important features:
- It is compatible with web development.
- It can be auto-configured.
We need to add the following dependency in the pom.xml file for Spring Boot Starter Web:
XML <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.2.2.RELEASE</version> </dependency>
It uses Spring MVC, REST, and Tomcat as a default embedded server. The single spring-boot-starter-web dependency can pull in all dependencies related to web development. It also reduces the count of build dependency. The spring-boot-starter-web mainly depends on the following:
- org.springframework.boot:spring-boot-starter
- org.springframework.boot:spring-boot-starter-tomcat
- org.springframework.boot:spring-boot-starter-validation
- com.fasterxml.jackson.core:jackson-databind
- org.springframework:spring-web
- org.springframework:spring-webmvc
By default, the spring-boot-starter-web contains the below tomcat server dependency given:
XML <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <version>2.0.0.RELEASE</version> <scope>compile</scope> </dependency>
The spring-boot-starter-web auto-configures the below things required for the web development:
- Dispatcher Servlet
- Error Page
- Embedded servlet container
- Web JARs for managing the static dependencies
Spring Boot also supports Jetty Server and Undertow Server. They are embedded web servers. We can also exclude spring-boot-starter-tomcat from spring-boot-starter-web as follows:
XML <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>
Spring Boot Starter Tomcat
While the spring-boot-starter-tomcat has everything related to the Tomcat server. It has
It has the below dependencies
XML <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>
Difference Between Spring Boot Starter Web and Spring Boot Starter Tomcat
Spring Boot Starter Web | Spring Boot Starter Tomcat |
---|
Spring Boot Starter Web is used for building RESTful applications using Spring MVC. | Spring Boot Starter Tomcat is the default embedded container for Spring Boot Starter Web. |
We cannot exclude it while using web services. | We can exclude it when we want to use another embedded container. |
It also supports Jetty Server and Undertow Server. | It acts as an embedded web server. |
It auto-configures Dispatcher Servlet, Error Page, Embedded servlet container, and Web JARs for managing the static dependencies for web development. | It has a core, el. logging, WebSocket. |
It contains spring web dependencies. | It contains everything related to an embedded tomcat server. |
It auto-configures the features used for web development. | It is used as the default embedded container. |
Similar Reads
Spring Boot Integration With MongoDB as a Maven Project MongoDB is a NoSQL database and it is getting used in software industries a lot because there is no strict schema like RDBMS that needs to be observed. It is a document-based model and less hassle in the structure of the collection. In this article let us see how it gets used with SpringBoot as a Ma
4 min read
Spring Boot MockMVC Example Automated testing plays a vital role in the software industry. In this article, let us see how to do the testing using MockMvc for a Spring Boot project. To test the web layer, we need MockMvc and by using @AutoConfigureMockMvc, we can write tests that will get injected. SpringBootApplication is an
3 min read
Spring Boot Integration With PostgreSQL as a Maven Project PostgreSQL is a user-friendly versatile RDBMS. This article lets us see how to integrate Spring Data JPA with PostgreSQL. There are some conventions to be followed while using PostgreSQL. We will cover that also. Working with PostgreSQL We can easily create databases and tables in that. The below sc
3 min read
Spring Boot JPA Sample Maven Project With Query Methods In this article, let us see a sample maven project in Spring Boot JPA with Query methods. Spring Boot + JPA removes the boilerplate code and it will be enhanced much if we use query methods as well. Let us discuss this project with MySQL Connectivity for geeksforgeeks database and table name as "Con
6 min read
Spring Boot - Service Class Example for Displaying Response Codes and Custom Error Codes Sometimes the error or status messages in webpages would be different from the default error message thrown by Tomcat (or any other server). An important reason for this is websites want to look unique in their approach to their users. So, a customized page for displaying status codes is always bett
6 min read
Spring Boot - Create a Custom Auto-Configuration Usually, we might be taking a maven project or grade project for Spring Boot related projects. We will be adding the dependencies in pom.xml (in case of a maven project). In a spring application, Spring Boot auto-configuration helps to automatically configure by checking with the jar dependencies th
4 min read
Spring Boot - Consume Message Through Kafka, Save into ElasticSearch, and Plot into Grafana In this article, we are going to make a program to produce some data using Kafka Producer which will consume by the Kafka Consumer and save into the elastic search DB, and later on, plot that JSON data into the Grafana dashboard. Start with configuring all the required software and tool. Requirement
7 min read
How to Implement AOP in Spring Boot Application? AOP(Aspect Oriented Programming) breaks the full program into different smaller units. In numerous situations, we need to log, and audit the details as well as need to pay importance to declarative transactions, security, caching, etc., Let us see the key terminologies of AOP Aspect: It has a set of
10 min read
Spring Boot - AOP(Aspect Oriented Programming) The Java applications are developed in multiple layers, to increase security, separate business logic, persistence logic, etc. A typical Java application has three layers namely they are Web layer, the Business layer, and the Data layer. Web layer: This layer is used to provide the services to the e
4 min read
Spring Boot - Cache Provider The Spring Framework provides support for transparently adding caching to an application. The Cache provider gives authorization to programmers to configure cache explicitly in an application. It incorporates various cache providers such as EhCache, Redis, Guava, Caffeine, etc. It keeps frequently a
6 min read