• 【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

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

  • 相关阅读:
    Java——Math,Set,List,map相关练习
    Java——单例模式、多线程
    Java——I/O入门相关练习代码
    Java——I/O相关练习代码
    Java——序列化与反序列化
    python-selenium-粘贴,删除,复制和悬停
    Typora图床设置(阿里云版,图片自动上传)
    图书管理系统(Java实现,十个数据表,含源码、ER图,超详细报告解释,2020.7.11更新)
    openresty的安装和使用
    工具丨超好用的免费AWR分析工具
  • 原文地址:https://www.cnblogs.com/sxdcgaq8080/p/5704178.html
Copyright © 2020-2023  润新知