我曾经将一些从依赖项中提取的资源提取到我的项目的结果WAR中(作为覆盖)。但由于我添加了对依赖项插件的unpack目标的调用,似乎只有来自ZIP存档的资源被嵌入到该WAR中。
<groupId>com.xxx.custom.www.yyy</groupId>
<artifactId>www-yyy-war</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.xxx.custom.www.yyy</groupId>
<artifactId>www-yyy-import</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.xxx.custom.www.yyy</groupId>
<artifactId>www-yyy-export</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.xxx.www</groupId>
<artifactId>www-server</artifactId>
<version>${www.version}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<overlays>
<overlay />
<overlay>
<groupId>com.xxx.www</groupId>
<artifactId>www-server</artifactId>
<type>war</type>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>我想要的是将ZIP资源添加到现有资源中。但在这里,我最终只得到了ZIP资源。
<dependencies>
<dependency>
<groupId>com.xxx.custom.www.yyy</groupId>
<artifactId>www-yyy-etat</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
...
</dependencies>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.xxx.custom.www.yyy</groupId>
<artifactId>www-xxx-etat</artifactId>
<version>${project.version}</version>
<type>zip</type>
<outputDirectory>${project.build.directory}/war/work/com.xxx.www/www-server/WEB-INF/classes</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>有没有人知道一个问题,或者看到我做错了什么?非常感谢您的帮助或建议。
发布于 2019-07-19 17:00:55
我终于发现overlays可以处理不同的类型,所以答案是:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<overlays>
<overlay />
<overlay>
<groupId>com.xxx.www</groupId>
<artifactId>www-server</artifactId>
<type>war</type>
</overlay>
<overlay>
<groupId>com.xxx.custom.www.yyy</groupId>
<artifactId>www-yyy-etat</artifactId>
<type>zip</type>
<outputDirectory>WEB-INF/classes</outputDirectory>
</overlay>
</overlays>
</configuration>
</plugin>不需要maven-dependency-plugin。
https://stackoverflow.com/questions/57062929
复制相似问题