【问题标题】:Spring Boot Exclude Tomcat DependencySpring Boot 排除 Tomcat 依赖
【发布时间】:2016-08-19 07:52:20
【问题描述】:

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

  • 将战争部署到单独的独立 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>

【问题讨论】:

  • 你为什么不试试呢?如果它有效,请在 github 上打开一个问题。

标签: tomcat spring-boot jhipster


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2017-07-05
    • 2017-09-28
    • 2015-04-28
    • 2016-10-24
    • 2017-11-11
    • 2019-11-25
    • 2016-06-29
    • 2020-09-10
    • 2021-12-29
    相关资源
    最近更新 更多