报错信息:

E:\MIKEY\mikey\HTML5\TestMaven_01>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building TestMaven_01 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ Hello ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\MIKEY\mikey\HTML5\TestMaven_01\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ Hello ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ Hello ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ Hello ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ Hello ---
[INFO] Surefire report directory: E:\MIKEY\mikey\HTML5\TestMaven_01\target\surefire-reports -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.mikey.www.maven.HelloTest
hello
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.061 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ Hello ---
[INFO] Packaging webapp
[INFO] Assembling webapp [Hello] in [E:\MIKEY\mikey\HTML5\TestMaven_01\target\Hello-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Webapp assembled in [158 msecs]
[INFO] Building war: E:\MIKEY\mikey\HTML5\TestMaven_01\target\Hello-0.0.1-SNAPSHOT.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.280s
[INFO] Finished at: Mon Aug 20 07:24:53 CST 2018
[INFO] Final Memory: 8M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project Hello: 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
E:\MIKEY\mikey\HTML5\TestMaven_01>

报错原因:

原因:找不到web.xml,但是项目中明明有这个文件,在WebContent/WEB-INF/文件夹下,就是识别不了

解决方法:

需要在pom.xml文件中,加上maven-war-plugin插件配置
在<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>

如果项目中原本没有web.xml文件,就需要加上下面的配置:

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>

结果:

最新文章

  1. adb工具获取appPackage和appActivity
  2. struts2笔记
  3. JS重点特性——闭包详解
  4. PHP合并数组+与array_merge的区别分析
  5. Jsoup代码解读之三-Document的输出
  6. 黄聪:Microsoft Enterprise Library 5.0 系列教程(八) Unity Dependency Injection and Interception
  7. DUIlib使用Fastreport--报表简单使用
  8. Android如何监听蓝牙耳机的按键事件(转)
  9. webpack web-dev-server 热加载
  10. git删除本地分支
  11. 深度学习篇——Tensorflow-GPU配置
  12. poj 3696 The Luckiest Number
  13. linux架构师之路!
  14. p1211 Prime Cryptarithm
  15. WeUI中的Css详解
  16. Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)
  17. Oracel官网下载各类版本的JDK
  18. Sed命令n,N,d,D,p,P,h,H,g,G,x解析3
  19. VS2010中使用 SpecFlow + Selenium.WebDriver
  20. JS中,split()用法(将字符串按指定符号分割成数组)

热门文章

  1. 浏览器渲染页面原理,reflow、repaint及其优化
  2. java将小写金额转换为大写的工具类
  3. 存储引擎:engine
  4. PHP基础学习笔记3
  5. 【PAT甲级】1092 To Buy or Not to Buy (20 分)
  6. hadoop学习笔记(一):NameNade持久化和DataNode概念
  7. 《一篇文章读懂HTTPS及其背后的加密原理》阅读笔记
  8. Java AQS 的胡言乱语修正版
  9. leetcode菜鸡斗智斗勇系列(10)--- Decrypt String from Alphabet to Integer Mapping
  10. 创建DataTable与DataGridView进行绑定