+-
spring-boot-starter-tomcat vs spring-boot-starter-web
我正在尝试学习 Spring启动,我注意到有两种选择.

> spring-boot-starter-web – 根据文档提供对全栈Web开发的支持,包括Tomcat和web-mvc
> spring-boot-starter-tomcat

由于#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-tomcat可能会自行使用(包含在spring-boot-starter-web中).

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

enter image description here

What are the differences?

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

弹簧引导启动
杰克逊
弹簧核心
春天MVC
弹簧引导起动的tomcat

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

核心
埃尔
记录
的WebSocket

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

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

<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 vs spring-boot-starter-web - 乐贴网