【问题标题】:Tomcat and spring-boot-starterTomcat 和 spring-boot-starter
【发布时间】:2019-08-23 15:48:30
【问题描述】:

我有一些 Spring Boot 2.1 应用程序,它们都托管在 Tomcat 8.5 上 我们一般使用如下POM.xml结构:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

我们面临的问题是大小,我们意识到 spring-boot-started 需要很多 MB,而我们有另一个应用程序仅使用:spring-boot-starter-webspring-boot-starter-tomcat 并且大小从50MB 到 10MB。

假设我们只使用 Tomcat,除了开发我们使用 mvn spring-boot run,如果我删除 spring-boot-starter 会发生什么?我可以有一个只有spring-boot-starter-webspring-boot-starter-tomcat 的应用程序,但在开发过程中仍然可以使用mvn spring-boot run 吗?

【问题讨论】:

    标签: java spring spring-boot tomcat


    【解决方案1】:

    请参阅 ltalhouarnethis 回答。

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

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

    只需包含spring-boot-starter-web 就足够了。

    【讨论】:

    • 超级,我会这样做的。它应该会大大减少 .war 的大小
    猜你喜欢
    • 2016-01-29
    • 2015-07-07
    • 2021-05-02
    • 2017-02-19
    • 2014-04-07
    • 2019-10-28
    • 1970-01-01
    • 2020-07-02
    • 1970-01-01
    相关资源
    最近更新 更多