如果我将mack-war-plugin配置为在缺少web.xml时失败,为什么缺少web.xml失败呢? [英] Why is maven-war-plugin failing for web.xml missing if I configured it not to fail on missing web.xml?
问题描述
这是一个挑战:为什么这个版本失败了?
Here's a challenge: why is this build failing?
我已经配置了Maven的maven-war-plugin在一个绝对的web.xml文件中不会失败,似乎:
I have configured Maven's maven-war-plugin not to fail on an abscent web.xml file, it seems:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>prepare-war</id>
<phase>prepare-package</phase>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archiveClasses>false</archiveClasses>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix />
</manifest>
<manifestEntries>
<Implementation-Build>${build.number}</Implementation-Build>
<Implementation-Title>${project.name}</Implementation-Title>
<Built-By>${user.name}</Built-By>
<Built-OS>${os.name}</Built-OS>
<Build-Date>${build.date}</Build-Date>
</manifestEntries>
</archive>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>./target/dist</directory>
</resource>
</webResources>
</configuration>
</execution>
</executions>
</plugin>
但是尽管有这样的配置,它仍然会像这样失败:
But despite of this configuration it keeps failing like this:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project com.specktro.orchid.operations.portal.frontend: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
我实际上没有web.xml,所以我需要它来组装没有它的战争。
I actually don't have the web.xml, so I need it to assemble the war without it.
我尝试在配置中添加一个伪造的< webXml> none< / webXml>
,但这并没有改变任何事情......
I tried adding a bogus <webXml>none</webXml>
into the config, but that didn't change anything...
我缺少什么?
推荐答案
POM中的执行ID是 prepare-war
。 Maven为包装类型为 war
的项目运行自己的war插件默认执行。默认执行具有ID default-war
。由于当前配置了POM, war
目标正在运行两次。
The execution ID in the POM is prepare-war
. Maven runs its own default execution of the war plugin for projects with packing type war
. The default execution has ID default-war
. As the POM is currently configured, the war
goal is running twice.
如果查看错误消息:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project com.specktro.orchid.operations.portal.frontend: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
您可能会在括号中看到失败的执行ID(默认战)
。如果您将执行ID更改为 default-war
,您的问题将会消失,并且您将不再执行两次战争目标的执行。
You may see the execution ID that fails in parenthesis (default-war)
. If you change the execution ID to default-war
your problem will go away, AND you will no longer have two executions of the war goal running.
这篇关于如果我将mack-war-plugin配置为在缺少web.xml时失败,为什么缺少web.xml失败呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!