缩小后,我的 webapp
内容如下:
WEB-INF
assets
favicon
i18n
scripts
dist
index.html
//other things
在dist
里面我有压缩的样式、脚本等...但是Maven WAR插件
将所有内容复制到WAR,这导致WAR包含未压缩的源代码。我尝试更改 webResources
的目录:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
packagingExcludes>WEB-INF/lib/tomcat-*.jar</packagingExcludes>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp/dist</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
但是什么都没有改变。谁能帮我这个?预先感谢您的每一个回答。
最佳答案
packagingExcludes
接受不包含的资源的逗号分隔列表。将您想要排除的所有目录添加到其中,例如
<packagingExcludes>
WEB-INF/lib/tomcat-*.jar,
scripts
</packagingExcludes>
您还需要确保资源不包含在 Maven 资源插件中。
我建议将所有不希望出现在 war 文件中的文件移出目录,而不是手动处理所有排除项,maven 默认情况下希望包含资源。您可以将它们移至例如src/main/uncompressedResources.这样它们仍然会在项目中,但 Maven 默认情况下不会包含它们。
关于java - Maven WAR 插件 - 更改前端资源位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39556086/