zhongguogu / Spring

0 stars 0 forks source link

spring-boot-starter-tomcat vs spring-boot-starter-web #1

Open zhongguogu opened 5 years ago

zhongguogu commented 5 years ago

Since #1 supports Tomcat why would one want to use #2?

spring-boot-starter-web contains spring-boot-starter-tomcat. spring-boot-starter-tomcat could potentially be used on its own if spring mvc isn't needed (contained in spring-boot-starter-web).

Here is the dependency hierarchy of spring-boot-starter-web:

enter image description here

What are the differences?

spring-boot-starter-web contains spring web dependencies (including spring-boot-starter-tomcat):

spring-boot-starter jackson spring-core spring-mvc spring-boot-starter-tomcat

spring-boot-starter-tomcat contains everything related to an embdedded tomcat server:

core el logging websocket

What if you want to use spring mvc without the embedded tomcat server?

Just exclude it from the dependency:

org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-tomcat
zhongguogu commented 5 years ago

https://stackoverflow.com/questions/33419823/spring-boot-starter-tomcat-vs-spring-boot-starter-web