【maven 报错】maven项目执行maven install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)

 

在使用maven新建的web项目中,执行

【maven   报错】maven项目执行maven  install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)

 

执行如上的这两个操作,报错:

【maven   报错】maven项目执行maven  install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)【maven   报错】maven项目执行maven  install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)
 1 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project bioligyInfo: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre1.8.0_73\..\lib\tools.jar -> [Help 1]
 2 [ERROR] 
 3 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
 4 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
 5 [ERROR] 
 6 [ERROR] For more information about the errors and possible solutions, please read the following articles:
 7 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
 8 
 9 
10 
11 
12 
13 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project bioligyInfo: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
14 [ERROR] 
15 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
16 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
17 [ERROR] 
18 [ERROR] For more information about the errors and possible solutions, please read the following articles:
19 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
View Code

上面的两种错误,提示的很明显:

错误1:

【maven   报错】maven项目执行maven  install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)

 

其实不用从maven下载插件,只需要保证你的pom.xml文件中有如下的信息即可:

【maven   报错】maven项目执行maven  install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)【maven   报错】maven项目执行maven  install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)
 1  <build>
 2       <plugins>
 3           <plugin>
 4               <artifactId>maven-war-plugin</artifactId>
 5               <configuration>
 6                   <version>2.5</version>
 7               </configuration>
 8           </plugin>
 9       </plugins>
10   </build>
11   
12   <properties>                                                                                                
13        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>                                  
14        <spring.version>4.1.4.RELEASE</spring.version>                                                      
15        <hibernate.version>4.3.8.Final</hibernate.version>                                                  
16        <jackson.version>2.5.0</jackson.version>                                                            
17                                                                                                            
18    </properties>  
View Code

 

错误2:

【maven   报错】maven项目执行maven  install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)

 

 提示找不到web.xml文件

解决方法:

1》如果你没有配置web.xml文件,那就创建web.xml文件

2》如果你配置了web.xml文件,还有这样的错误,那就是你的web.xml文件不能被你项目读取到

如下,项目中web.xml的位置如下:

【maven   报错】maven项目执行maven  install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)

 

而我们需要让项目读取到它:

【maven   报错】maven项目执行maven  install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)

因为web.xml文件的路径如下:src\main\webapp\WEB-INF\web.xml

 

如果依旧无法解决,那就在pom.xml文件中配置如下:

【maven   报错】maven项目执行maven  install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)【maven   报错】maven项目执行maven  install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)
 1   <build>
 2       <plugins>
 3           <plugin>
 4               <artifactId>maven-war-plugin</artifactId>
 5               <configuration>
 6                   <version>2.5</version>
 7               <webXml>src\main\webapp\WEB-INF\web.xml</webXml>
 8               </configuration>
 9           </plugin>
10       </plugins>
11   </build>
View Code

这样指定到具体的文件上  就可以解决这问题了。

 

上一篇:如何确定CPU瓶颈


下一篇:超级码力在线编程大赛开启(集赞赢礼品!)