maven使用过程中遇到的问题总汇

1:web.xml is missing and <failOnMissingWebXml> is set to true

 造成原因:

使用maven创建项目时有时在pom.xml的war处出现failOnMissingWebXml的错误,根据错误提示的原因可以知道项目是web项目,打包时打成war包。

如果项目里没有web.xml,在项目里添加一个web.xml,刷新一下项目,就应该没有错误,如果还有请看下面的介绍

 如果你的项目在 /src/main/webapp/WEB-INF 下有web.xml,但是仍然还是报这个错误,需要两步操作

1)右击项目,打开Properties对话框,点击Deployment Assembly选项,在右边添加一个文件夹,并且保存设置

2)在eclispe上方点击Project ->Clean 清理一下这个项目

经过这两步错误就应该已经清楚了

还有一种网上很常见的做法

有提供一个变相规避错误的方法,添加配置,放过该错误提示。

 1 <build>  
 2     <plugins>  
 3         <plugin>  
 4             <groupId>org.apache.maven.plugins</groupId>  
 5             <artifactId>maven-war-plugin</artifactId>  
 6             <version>2.3</version>  
 7             <configuration>  
 8                 <failOnMissingWebXml>false</failOnMissingWebXml>  
 9             </configuration>  
10         </plugin>  
11     </plugins>  
12 </build>  

2:把项目打成jar包放到本地仓库 以便让别的项目依赖

 

   ps:在开发阶段可以直接写绝对路径 在发布的时候在改回来 避免了频繁打成jar包

2:maven 与 jdk版本配置不兼容

1 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project core-ssm: Compilation failure
2 [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
3 [ERROR] -> [Help 1]
4 [ERROR] 
5 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
6 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
7 [ERROR] 
8 [ERROR] For more information about the errors and possible solutions, please read the following articles:
9 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

在父工程的pom.xml文件中 修改jdk版本即可

 1    <build>
 2         <plugins>
 3             <plugin>
 4                 <groupId>org.apache.maven.plugins</groupId>
 5                 <artifactId>maven-compiler-plugin</artifactId>
 6                 <configuration>
 7                     <source>1.8</source>
 8                     <target>1.8</target>
 9                 </configuration>
10             </plugin>
11 
12         </plugins>
13     </build>

正常发布了 

原文地址:https://www.cnblogs.com/xuyou551/p/8081706.html