Maven打包web项目报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if

maven install web项目时报错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project spring2: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

原因分析
maven的web项目默认的webroot是在src\main\webapp。如果在此目录下找不到web.xml就抛出以上的异常。

解决办法

  1. 将webroot修改为webapp
  2. 在pom.xml中指定web.xml,如下:
<build>
    <finalName>web-app-namefinalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.pluginsgroupId>
            <artifactId>maven-war-pluginartifactId>
            <version>2.2version>
            <configuration>
                <webXml>WebContent\WEB-INF\web.xmlwebXml>
            configuration>
        plugin>
    plugins>
build>

你可能感兴趣的:(Maven)