【maven】web项目不需要web.xml,maven打包报错

来源:互联网 发布:2017中超球员数据 编辑:程序博客网 时间:2024/06/05 13:28

在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/

阅读全文
0 0
原创粉丝点击