cuiyi's blog(崔毅 crazycy)

记录点滴 鉴往事之得失 以资于发展
数据加载中……

SpringMVC+MyBatis - 16 Maven部署Web项目报错webxml attribute is required

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

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

Solution:
需要在pom.xml中增加<webResources>配置,如下:

 <build>  
<plugins>  
    <plugin>  
        <groupId>org.apache.maven.plugins</groupId>  
        <artifactId>maven-war-plugin</artifactId>  
        <version>2.4</version>  
        <configuration>  
            <webResources>  
                <resource>                      
                    <directory>WebContent</directory>  
                </resource>  
            </webResources>  
        </configuration>  
    </plugin>  
</plugins>  
</build>  


或者增加<webXml>配置,如下:

<build>  
<plugins>  
    <plugin>  
        <groupId>org.apache.maven.plugins</groupId>  
        <artifactId>maven-war-plugin</artifactId>  
        <version>2.4</version>  
        <configuration>  
               <webXml>WebContent\WEB-INF\web.xml</webXml>            
        </configuration>  
    </plugin>  
</plugins>  
</build>  

posted on 2014-10-02 17:56 crazycy 阅读(2827) 评论(0)  编辑  收藏 所属分类: JavaEE技术


只有注册用户登录后才能发表评论。


网站导航: