• 【maven 报错】maven项目执行maven install时报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)


    在使用maven新建的web项目中,执行

    执行如上的这两个操作,报错:

     1 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project bioligyInfo: Fatal error compiling: tools.jar not found: C:Program FilesJavajre1.8.0_73..lib	ools.jar -> [Help 1]
     2 [ERROR] 
     3 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
     4 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
     5 [ERROR] 
     6 [ERROR] For more information about the errors and possible solutions, please read the following articles:
     7 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
     8 
     9 
    10 
    11 
    12 
    13 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project bioligyInfo: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
    14 [ERROR] 
    15 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    16 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    17 [ERROR] 
    18 [ERROR] For more information about the errors and possible solutions, please read the following articles:
    19 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    View Code

    上面的两种错误,提示的很明显:

    错误1:

    其实不用从maven下载插件,只需要保证你的pom.xml文件中有如下的信息即可:

     1  <build>
     2       <plugins>
     3           <plugin>
     4               <artifactId>maven-war-plugin</artifactId>
     5               <configuration>
     6                   <version>2.5</version>
     7               </configuration>
     8           </plugin>
     9       </plugins>
    10   </build>
    11   
    12   <properties>                                                                                                
    13        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>                                  
    14        <spring.version>4.1.4.RELEASE</spring.version>                                                      
    15        <hibernate.version>4.3.8.Final</hibernate.version>                                                  
    16        <jackson.version>2.5.0</jackson.version>                                                            
    17                                                                                                            
    18    </properties>  
    View Code

    错误2:

     提示找不到web.xml文件

    解决方法:

    1》如果你没有配置web.xml文件,那就创建web.xml文件

    2》如果你配置了web.xml文件,还有这样的错误,那就是你的web.xml文件不能被你项目读取到

    如下,项目中web.xml的位置如下:

    而我们需要让项目读取到它:

    因为web.xml文件的路径如下:srcmainwebappWEB-INFweb.xml

    如果依旧无法解决,那就在pom.xml文件中配置如下:

     1   <build>
     2       <plugins>
     3           <plugin>
     4               <artifactId>maven-war-plugin</artifactId>
     5               <configuration>
     6                   <version>2.5</version>
     7               <webXml>srcmainwebappWEB-INFweb.xml</webXml>
     8               </configuration>
     9           </plugin>
    10       </plugins>
    11   </build>
    View Code

    这样指定到具体的文件上  就可以解决这问题了。

  • 相关阅读:
    无限分类 引用传值
    jQeury 自动、手动左右切换
    $_POST 为空时 真正的值
    php isset 备忘
    php empty 备忘
    无限分级函数 简单 引用绑值
    无限分级 层次输出 demo
    利用新版ShareSDK进行手动分享(自定义分享界面)
    eclipse 快捷方式大全
    ViewPager onPageChangeListener总结
  • 原文地址:https://www.cnblogs.com/sxdcgaq8080/p/5704178.html
Copyright © 2020-2023  润新知