【问题标题】:How to remove tomcat-embedded dependency?如何删除tomcat嵌入的依赖项?
【发布时间】:2020-07-02 12:05:31
【问题描述】:

我有一个 Spring Boot 应用程序,我想在 weblogic 上部署,所以我不需要嵌入的 tomcat 依赖项(否则它会崩溃)。

这个 Spring Boot 应用程序还包含一个库 jar,它仅在编译时需要 spring-boot-starter-web 依赖项。所以,我为tomcat依赖项“提供”了以下pom。在最终的.war中,tomcat仍然存在!有没有办法查看它来自哪里?没有必要,因为手动将其从我的 .war 中删除会使其成功运行...

mylibrary.pom

<dependencies>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
    </dependency>

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>

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

myapplication.pom

<packaging>war</packaging>

<properties>
    <java.version>1.8</java.version>
</properties>

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
    </dependency>

    <dependency>
        <groupId>com.myself</groupId>
        <artifactId>my-library</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>org.redisson</groupId>
        <artifactId>redisson-spring-data-22</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <archive>
                    <manifest>
                        <addDefaultImplementationEntries>false</addDefaultImplementationEntries>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

编辑 运行maven dependency:tree 说是提供的,那为什么会在战争中呢?

[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.2.5.RELEASE:provided
[INFO] |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.31:provided
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.31:provided
[INFO] |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.31:provided

【问题讨论】:

  • 你可以运行mvn dependency:tree来查看哪个依赖来自哪里。
  • 已编辑...我还是看不懂:(

标签: spring-boot maven weblogic12c


【解决方案1】:

为tomcat提供的依赖是正确的,我的问题是我之前需要做一个mvn clean:目标目录仍然有tomcat依赖并且它被包含在war中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-02
    • 2015-06-15
    • 2017-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多