Maven使用常见问题总结及解决方案

Maven使用常见问题总结及解决方案

相信很多人都知道maven,在工作开发中可能会经常碰到各类maven编译的问题, 下面我会逐步的去总结一些maven在日常工作中遇到的一些问题及解决的方案

  1. 开发过程中如果有用到json-lib,可能会在编译的时候出现以下问题:

[ERROR]Failure to find net.sf.json-lib:json-lib:jar:2.4 in http://repo.maven.apache.org/maven2 was cached in the local repository
resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

  解决方案需要在pom.xml添加以下内容:

<!--json-lib-->
<dependency>
    <groupId>net.sf.json-lib</groupId>
    <artifactId>json-lib</artifactId>
    <version>2.4</version>
    <classifier>jdk15</classifier>
</dependency>

  

   2. 开发过程中有的时候编译项目可能会遇到以下问题:

java.lang.ClassCastException: org.springframework.web.servlet.DispatcherServlet cannot be cast to javax.servlet.Servlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)

  解决方案是需要在pom.xml添加以下内容:

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>


    3. maven项目编译过程可能会经常以下问题:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project dubbo-common: There are test failures.

   解决方案是编译命令行加上 -Dmaven.test.skip

mvn clean install -Dmaven.test.skip


你可能感兴趣的:(maven使用)