• Maven打包项目失败;报错: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/we


    报错信息:

    E:MIKEYmikeyHTML5TestMaven_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:MIKEYmikeyHTML5TestMaven_01srcmain
    esources
    [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:MIKEYmikeyHTML5TestMaven_01	argetsurefire-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:MIKEYmikeyHTML5TestMaven_01	argetHello-0.0.1-SNAPSHOT]
    [INFO] Processing war project
    [INFO] Webapp assembled in [158 msecs]
    [INFO] Building war: E:MIKEYmikeyHTML5TestMaven_01	argetHello-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:MIKEYmikeyHTML5TestMaven_01>
    View Code

    报错原因:

     原因:找不到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>

    结果:

    合群是堕落的开始 优秀的开始是孤行
  • 相关阅读:
    Power BI for Office 365(八)共享查询
    Power BI for Office 365(七) Power BI站点
    Power BI for Office 365(六)Power Map简介
    Power BI for Office 365(五)Power View第二部分
    Power BI for Office 365(四)Power View第一部分
    Power BI for Office 365(三)Power Pivot
    Power BI for Office 365(二)Power Query
    java 继承、重载、重写与多态
    Android 热修复方案Tinker(一) Application改造
    阿里最新热修复Sophix与QQ超级补丁和Tinker的实现与总结
  • 原文地址:https://www.cnblogs.com/biaogejiushibiao/p/9503565.html
Copyright © 2020-2023  润新知