java – 为什么maven-war-plugin失败的web.xml失败,如果我配置它不失败在缺少web.xml?

前端之家收集整理的这篇文章主要介绍了java – 为什么maven-war-plugin失败的web.xml失败,如果我配置它不失败在缺少web.xml?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_502_0@
这是一个挑战:为什么这个构建失败?

我已经配置了Maven的maven-war-plugin不会在一个缺失的web.xml文件中失败,似乎:

  1. <plugin>
  2. <groupId>org.apache.maven.plugins</groupId>
  3. <artifactId>maven-war-plugin</artifactId>
  4. <executions>
  5. <execution>
  6. <id>prepare-war</id>
  7. <phase>prepare-package</phase>
  8. <configuration>
  9. <failOnMissingWebXml>false</failOnMissingWebXml>
  10. <archiveClasses>false</archiveClasses>
  11. <archive>
  12. <manifest>
  13. <addClasspath>true</addClasspath>
  14. <classpathPrefix />
  15. </manifest>
  16. <manifestEntries>
  17. <Implementation-Build>${build.number}</Implementation-Build>
  18. <Implementation-Title>${project.name}</Implementation-Title>
  19. <Built-By>${user.name}</Built-By>
  20. <Built-OS>${os.name}</Built-OS>
  21. <Build-Date>${build.date}</Build-Date>
  22. </manifestEntries>
  23. </archive>
  24. <webResources>
  25. <resource>
  26. <!-- this is relative to the pom.xml directory -->
  27. <directory>./target/dist</directory>
  28. </resource>
  29. </webResources>
  30. </configuration>
  31. </execution>
  32. </executions>
  33. </plugin>

但是尽管有这样的配置,它仍然像以下这样失败:

  1. [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,所以我需要它组装没有它的战争.

我尝试添加一个假的< webXml> none< / webXml>进入配置,但是没有改变任何东西…

我失踪了什么

解决方法

POM中的执行ID是准备战争.对于包装类型为war的项目,Maven运行自己的默认的war插件.默认执行有ID default-war.由于POM目前配置,战争目标是两次.

如果您看到错误信息:

  1. [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在括号(default-war)中失败.如果您将执行ID更改为default-war,您的问题将会消失,您将不会再执行两次战争目标.

猜你在找的Java相关文章