java项目在用maven打包的时候遇到:

  1. [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打包项目的时候,出现错误:
webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update)
原因分析
web项目下缺少WEB-INF/web.xml
当是在servlet 3.0.0之后,对于web.xml文件本身是可选的。只要把maven-war-plugin更新到3.0.0就好。如下:

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.apache.maven.plugins</groupId>
  5. <artifactId>maven-compiler-plugin</artifactId>
  6. <version>3.8.1</version>
  7. <configuration>
  8. <source>1.8</source>
  9. <target>1.8</target>
  10. <encoding>UTF-8</encoding>
  11. </configuration>
  12. </plugin>
  13. <plugin>
  14. <groupId>org.apache.maven.plugins</groupId>
  15. <artifactId>maven-war-plugin</artifactId>
  16. <version>3.0.0</version>
  17. </plugin>
  18. </plugins>
  19. </build>

分类: web

标签:   maven   java