eclipse创建的maven丢失/WEB-INF/web.xml文件

今天开始学习maven搭建项目, 不想第一个项目构建(maven install)就出错, 错误内容如下:

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.cnp.x8:x8:war:0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ line 93, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building x8 Maven Webapp 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ x8 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ x8 ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ x8 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ x8 ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ x8 ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-war-plugin:2.4:war (default-war) @ x8 ---
[INFO] Packaging webapp
[INFO] Assembling webapp [x8] in [W:\devTools\eclipse\workspace\maven\simple-webapp\target\x8]
[INFO] Processing war project
[INFO] Copying webapp resources [W:\devTools\eclipse\workspace\maven\simple-webapp\src\main\webapp]
[INFO] Webapp assembled in [41 msecs]
[INFO] Building war: W:\devTools\eclipse\workspace\maven\simple-webapp\target\x8.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.198 s
[INFO] Finished at: 2015-04-18T00:18:00+08:00
[INFO] Final Memory: 12M/170M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project x8: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

 通过百度, 找到以下内容:

eclipse创建的maven丢失/WEB-INF/web.xml文件_第1张图片
 但是在当前项目就一直没发现 /WEB-INF/web.xml 的踪迹, 仅仅在首次执行 maven install 时, 在target中有看到. 当时没注意 /main/webapp/ 下没有. 具体原因暂未找到, 目前解决方案: 手动创建 /main/webapp/WEB-INF/web.xml 文件.

 

原因已找到:

eclipse创建的maven丢失/WEB-INF/web.xml文件_第2张图片
1. 默认生成的没有WEB-INF/web.xml(...quickstart)

2. 应选择 maven...webapp 选项

你可能感兴趣的:(maven,web.xml)