• spring-boot-maven-plugin插件 —— 排除依赖


    默认情况下,repackage 和 run 目标会包含任何定义在项目中的 provided 依赖。Spring Boot 项目会认为 provided 依赖是运行应用的容器所需的依赖。

    其中一些依赖项可能根本不需要,应该从可执行 jar 中排除。为了保持一致性,它们在运行应用程序时也不应该出现。

    有两种方式可以排除在运行时打包/使用依赖项:

    • 通过 groupId 和 artifactId 排除一个指定的依赖。
    • 指的 groupId 的来排除依赖。

    下面所示通过指定 groupId 和 artifactId 排除 com.xh:common-core依赖:

    1. <build>
    2.     <plugins>
    3.         <plugin>
    4.             <groupId>org.springframework.bootgroupId>
    5.             <artifactId>spring-boot-maven-pluginartifactId>
    6.             <version>${spring-boot-dependencies.version}version>
    7.             <configuration>
    8.                 <excludes>
    9.                     <exclude>
    10.                         <groupId>com.xhgroupId>
    11.                         <artifactId>common-coreartifactId>
    12.                     exclude>
    13.                 excludes>
    14.             configuration>
    15.         plugin>
    16.     plugins>
    17. build>


    下面所示,通过指定所属的 group 来排除依赖:

    1. <build>
    2.     <plugins>
    3.         <plugin>
    4.             <groupId>org.springframework.bootgroupId>
    5.             <artifactId>spring-boot-maven-pluginartifactId>
    6.             <version>${spring-boot-dependencies.version}version>
    7.             <configuration>
    8.                 <excludeGroupIds>com.xhexcludeGroupIds>
    9.             configuration>
    10.         plugin>
    11.     plugins>
    12. build>

  • 相关阅读:
    Java虚拟机二三事:虚拟机类加载机制
    Moonbeam通过新的LayerZero部署扩展跨链能力
    git——如何撤销已经push到远程的修改
    ODI报错
    Unity收费对谁影响最大
    MR混合现实情景实训教学系统模拟高空作业情景
    PHP8的静态变量和方法-PHP8知识详解
    【Java8】对JSONArray 按指定字段排序,升序和倒序,经典
    面试面经|java面试异常面试题
    【多线程】Thread类的基本用法
  • 原文地址:https://blog.csdn.net/xhaimail/article/details/134408796