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

http://blog.csdn.net/pange1991/article/details/48596869

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-name</finalName>
    <plugins>
        <plugin> <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <webXml>WebContent\WEB-INF\web.xml</webXml>
            </configuration>
        </plugin>
    </plugins>
</build>

posted @ 2017-06-09 15:25  LoveLife-Everyday  阅读(156)  评论(0)    收藏  举报