考虑:
当我创建一个简单的 Maven 时项目Eclipse我收到此错误:
web.xml is missing and
<failOnMissingWebXml>
is set to true
如何解决这个问题?
最佳答案
这是一个 Maven 错误。它表示您的项目中需要一个 web.xml 文件,因为它是一个 Web 应用程序,如 <packaging>war</packaging>
所示。 。然而,对于最近的 Web 应用程序来说,web.xml 文件是完全可选的。 Maven 需要 catch 这个约定。
将其添加到您的 Maven pom.xml
让maven catch 你不需要添加无用的web.xml
到您的项目:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
这是比添加空 web.xml
更好的解决方案因为这样您的最终产品就会保持干净,您只需更改构建参数即可。
对于最新版本的 Maven,您也可以使用较短的版本:
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
关于eclipse - web.xml 丢失且 <failOnMissingWebXml> 设置为 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31835033/