maven项目打包报错,没有web.xml问题

在maven 打包war包的时候,它会要求/WEB-INF目录下有web.xml文件,但是在servlet 3.0之后,对于web.xml文件本身是可选的,当我用maven打包的时候报错如下错误:

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project core-frontend: 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.

解决方式有两个: 
1 在pom.xml文件中定义一个参数配置

   <properties>
            <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>

2 另外你可以更新maven的默认的maven-war-plugin

<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <version>3.0.0</version>
</plugin>

参考: 
https://stackoverflow.com/questions/33390460/maven-error-assembling-war-webxml-attribute-is-required-when-building-the-sprin

https://www.mkyong.com/maven/maven-webxml-attribute-is-required/

猜你喜欢

转载自blog.csdn.net/hu_belif/article/details/82631142