gpt4 book ai didi

tomcat - Spring Boot 排除 Tomcat 依赖

转载 作者:行者123 更新时间:2023-11-28 23:26:07 25 4
gpt4 key购买 nike

默认JHipster配置 spring-boot-starter-webspring-boot-starter-tomcat 从其依赖项中排除。排除 tomcat 依赖项的原因可能包括:

  • 将 war 部署到单独的独立 Web 应用程序服务器中
  • 将 Tomcat 依赖项替换为另一个 Web 服务器,例如 Jetty

(摘自pom.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>

另外还提供了 2 个配置文件,用于在 devprod 环境中运行应用程序。这就是我的困惑开始的地方......

在每个配置文件中,声明了一个额外的依赖项:

    <profile>
<id>prod</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
</dependencies>
...
</profile>

spring-boot-starter-tomcat 依赖项是否需要从标准依赖项列表中排除,然后包含在配置文件中,这是有原因的吗?

从依赖项中删除排除项并具有:

不是更好吗?
    <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

最佳答案

这实际上是遗留代码:我们曾经有一个“快速”的配置文件,我们会使用 Undertow 而不是 Tomcat,这就是默认情况下删除 Tomcat 依赖项的原因。我们一直保留它,因为我们想再次迁移到 Undertow,但上次我们尝试时我们有 another issue ...所以也许我们应该删除它。

关于tomcat - Spring Boot 排除 Tomcat 依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36848771/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com