使用maven-shade-plugin我尝试创建一个项目文件结构,如下所示:
问题是以下pom配置没有创建WEB-INF目录。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<createDependencyReducedPom>true</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.my.package.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
基本上,我需要将 web.xml 文件、类和 lib 文件复制到项目根目录中名为 WEB-INF 的目录中。
更新:抱歉,我将错误的插件从我的 pom 复制到了原始问题中!
更新:如果我从 pom 声明中添加包装:<packaging>war</packaging>
WEB-INF 文件结构已按照 OQ 完成。然而,通过此声明 com
目录现在不包含我的包,因此无法找到主类。
<packaging>war</packaging>
的外观如何:
它应该是什么样子:
最佳答案
关于java - Maven 阴影复制 WEB-INF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24441349/