java - 为什么 spring-boot-maven 插件在重新打包覆盖的战争文件时会添加战争本身?
问题描述
我有以下内容pom.xml
:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>foo-war</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.jasig.portlet</groupId>
<artifactId>CalendarPortlet</artifactId>
<version>2.6.2</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.6.RELEASE</version>
<executions>
<execution>
<goals>
<goal>build-info</goal>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<overlays>
<overlay>
<groupId>org.jasig.portlet</groupId>
<artifactId>CalendarPortlet</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>
</project>
当我运行mvn package
生成的重新打包的战争文件时,它包含原始战争本身WEB-INF/lib/CalendarPortlet-2.6.2.war
。
为什么 spring-boot 在重新打包过程中会添加战争,我该如何防止这种情况?
在我的真实项目中,我想替换已经存在的战争的一些资源并添加构建信息以供执行器显示。但是仅仅为此将工件的大小增加一倍是不可行的。
编辑:
重新包装罐子时也会出现问题。
解决方案
可以通过在 spring-boot-maven 插件的配置中手动指定该工件的排除项来防止原始工件包含在重新打包的工件中:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.6.RELEASE</version>
<configuration>
<excludes>
<exclude>
<groupId>org.jasig.portlet</groupId>
<artifactId>CalendarPortlet</artifactId>
</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>build-info</goal>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
但我仍然不知道为什么该插件在重新打包的插件中包含原始工件。
推荐阅读
- android - 使用配置文件发布移动(React Native)工件
- python - 将变量传递到xpath selenium,Python
- java - 转换为 Scala 的 Java 泛型类型不接受超类本身
- c# - “CS1513:} 预期”错误
- c++ - Linux 中的点窗口 (C/C++)
- java - 图像未共享到应用程序
- regex - 使用正则表达式处理 linux shell 脚本字符串
- powershell - powershell处理命令输出
- r - 与 dplyr、tidyverse 和 broom 的相关矩阵 - P 值矩阵
- r - 散点图“if (counts[i] == 0) next 中的错误:参数的长度为零”