模块项目未声明为 war 包,但在 eclipse 中出现错误 'web.xml is missing and <failOnMissingWebXml> is set to true'

Module project is not declared as war package, but get error 'web.xml is missing and <failOnMissingWebXml> is set to true' in eclipse

模块项目在pom.xml之前被声明为war包,然后我删除了行<packaging>war</packaging>,当我运行时,我可以成功获得预期的XX.jar ] 命令行 mvn install,但是,我在 eclipse 中仍然遇到错误 web.xml is missing and <failOnMissingWebXml> is set to true

申请了好几次'Force update of snapshot/releases'都没用


pom.xml

<?xml version="1.0"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.xx</groupId>
        <artifactId>xxx</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <artifactId>xxx</artifactId>
    <name>xxxx</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>xxxx</groupId>
            <artifactId>xxxx</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

我发现有 Web 服务描述符,但不应该有。我没有找到任何方法可以删除描述符我将所有源文件复制到另一个文件夹,在 Eclipse 中创建另一个工作区并导入项目。一切正常。

刚刚遇到同样的问题 - 您需要生成一个 web.xml 文件。

在 Project Explorer 中右键单击“部署描述符”。 Select 生成部署描述符存根。 它将在 src/main/webapp 中生成 WEB_INF 文件夹,并在其中生成一个 web.xml。

谢谢

我有一个类似的问题 - 由于一些重构,maven 项目从 war 包变成了 jar。出乎意料地难以清除该死的标记 "web.xml is missing but failOnMissingWebXml is true".

我检查了 .classpath 和 .project 文件 - 特别是该项目有几个我删除的 WST 性质。之后,我终于从 Eclipse 中删除了该项目,但将文件留在磁盘上 ,然后将现有的 maven 项目重新导入到 Eclipse 中。这有效,我认为删除清除了所有隐藏的元数据。