第一步是创建一个专用的 Maven 模块,其封装类型jar包含web.xml. 我们称它为 com.mycompany:common。
  有没有可能做这样的事情?:
<webXml>classpath:com/mycompany/common/web.xml</webXml>
您是否尝试过,即您确定它不起作用?如果是这样,我想您必须使用前导“/”(/com/...)。
  当然,使该文件在插件的类路径中可用。
那么这很容易......只需向 com.mycompany:common 添加一个依赖项,使其在类路径中可用。当然,它必须在您的 Maven 存储库中可用。
如果classpath:不起作用,我自己真的不确定,您可以使用从 JAR 中maven-dependency-plugin解压缩web.xml以使其可用于maven-war-plugin.
pom.xml
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>unpack-web-xml</id>
      <phase>..any phase before packaging..</phase>
      <goals>
        <goal>unpack</goal>
      </goals>
      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>com.mycompany</groupId>
            <artifactId>common</artifactId>
            <version>1.0</version>
            <outputDirectory>...dir you'll use for the war plugin later...</outputDirectory>
            <includes>/com/mycompany/common/web.xml</includes>
          </artifactItem>
        </artifactItems>
      </configuration>
    </execution>
  </executions>
</plugin>