spring-boot-starter-tomcat和spring-boot-starter-web [英] spring-boot-starter-tomcat vs spring-boot-starter-web

查看:1655
本文介绍了spring-boot-starter-tomcat和spring-boot-starter-web的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习Spring boot,我注意到有两种选择.

I'm trying to learn Spring boot and I notice there are two options.

  1. spring-boot-starter-web-根据文档,它支持全栈式Web开发,包括Tomcat和web-mvc

  1. spring-boot-starter-web - which according to the docs gives support for full-stack web development, including Tomcat and web-mvc

spring-boot-starter-tomcat

spring-boot-starter-tomcat

由于#1支持Tomcat,为什么要使用#2?

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

有什么区别?

谢谢

推荐答案

由于#1支持Tomcat,为什么要使用#2?

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

spring-boot-starter-web包含spring-boot-starter-tomcat.如果不需要spring mvc(包含在spring-boot-starter-web中),则可以单独使用spring-boot-starter-tomcat.

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).

这是spring-boot-starter-web的依赖项层次结构:

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

有什么区别?

What are the differences?

spring-boot-starter-web包含spring web依赖项(包括spring-boot-starter-tomcat):

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
jackson
spring-core
spring-mvc
spring-boot-starter-tomcat

spring-boot-starter-tomcat包含与嵌入式tomcat服务器相关的所有内容:

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

core
el
logging
websocket

core
el
logging
websocket

如果您想在没有嵌入式tomcat服务器的情况下使用spring mvc怎么办?

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

只需将其从依赖项中排除:

Just exclude it from the dependency:

<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和spring-boot-starter-web的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆