java - 从 Spring Boot 中排除 Maven 依赖项

标签 java maven spring-boot

我有一个 springboot 项目,它将所有依赖的 jar 添加到 lib 文件夹中。 我怎样才能避免这种情况?

我试过了,但不起作用

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <!-- <excludeScope>compile</excludeScope>
                        <excludeArtifactIds>*</excludeArtifactIds>
                        <excludeGroupIds>*.*</excludeGroupIds> -->
        <exclude>
            <groupId>*.*</groupId>
            <artifactId>*</artifactId>
        </exclude>
    </configuration>
</plugin>

我不想将依赖项作为提供

还有其他解决方案吗?

最佳答案

您可以通过在 pom.xml 中指定不需要的依赖项来排除。 如下所示。

这里我不需要boot提供的嵌入式tomcat。因此我们可以使用以下标签排除它:

<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>

关于java - 从 Spring Boot 中排除 Maven 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35769105/

相关文章:

java - 如何将本地 Docker 镜像与 testcontainers 一起使用?

java - 如何使用 Jax-RS(Jersey) 在 Tomcat7 上运行应用程序 Hibernate 5.x、Jpa 2.1、Java EE7(javaee-api 7.0)

java - 将具有空布局的 JPanel 插入 JScroll

java - 无法使用MAVEN命令

java - 如何修复maven中的 "package javafx.util does not exist"

java - 如何在 Maven pom.xml 中定义属性并从命令行传递参数?

java - Spring Boot 预处理 JSON 数据

java - CAS 4 - 身份验证成功后无法检索 LDAP 组

spring - Spring Boot框架需要Spring安全管理控制台

java - Intellij 2019.1.3旗舰版无法安装maven依赖