maven 打包时的web.xml问题

maven web项目在打包时,报如下的错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project com.shihou.session.manager.service: 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

原因是,没有加载到web.xml

解决办法:

1.在项目路径下添加web.xml
2.在pom.xml中添加

<properties>
        <failOnMissingWebXml>falsefailOnMissingWebXml>
properties>

3.org.apache.maven.plugins修改为

<plugin>
    <groupId>org.apache.maven.pluginsgroupId>
    <artifactId>maven-war-pluginartifactId>
    <version>3.0version>
plugin>

4.maven-war-plugin中修改

<plugin>
    <groupId>org.apache.maven.pluginsgroupId>
    <artifactId>maven-war-pluginartifactId>
    <version>2.1version>
    <configuration>
        <failOnMissingWebXml>falsefailOnMissingWebXml>
    configuration>
plugin>

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

如果觉得文章真心好, 请打赏下我吧,程序员赚钱不容易。 十块八块不嫌多, 一块两块也是爱啊!
这里写图片描述

你可能感兴趣的:(java,MAVEN,JAVA)