我有一个小的maven pom.xml如下(源代码树不重要就是这个问题):
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.group</groupId>
<artifactId>maventest</artifactId>
<version>0.0.4-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jetty.version>9.4.6.v20170531</jetty.version>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<defaultGoal>package</defaultGoal>
<directory>target</directory>
<finalName>maventest</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<webAppSourceDirectory>${project.basedir}/WebContent</webAppSourceDirectory>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
<scanIntervalSeconds>1000</scanIntervalSeconds>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>2.1.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<outputDirectory>target/site/cobertura</outputDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
<dependencies>
</dependencies>
<packaging>war</packaging>
</project>
当我执行命令mvn jetty:run
时,它会提供如下日志:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maventest 0.0.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> jetty-maven-plugin:9.4.6.v20170531:run (default-cli) > test-compile @ maventest >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maventest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/my/workspace/maventest/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ maventest ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maventest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/my/workspace/maventest/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ maventest ---
[INFO] No sources to compile
[INFO]
[INFO] <<< jetty-maven-plugin:9.4.6.v20170531:run (default-cli) < test-compile @ maventest <<<
[INFO]
[INFO] --- jetty-maven-plugin:9.4.6.v20170531:run (default-cli) @ maventest ---
Downloading: http://myrepo.com/repo/org/mortbay/jetty/servlet-api-2.5/6.1.14/servlet-api-2.5-6.1.14.pom
Downloaded: http://myrepo.com/repo/org/mortbay/jetty/servlet-api-2.5/6.1.14/servlet-api-2.5-6.1.14.pom (4 KB at 15.0 KB/sec)
Downloading: http://myrepo.com/repo/org/mortbay/jetty/project/6.1.14/project-6.1.14.pom
Downloaded: http://myrepo.com/repo/org/mortbay/jetty/project/6.1.14/project-6.1.14.pom (9 KB at 1072.3 KB/sec)
Downloading: http://myrepo.com/repo/org/mortbay/jetty/jetty-parent/7/jetty-parent-7.pom
Downloaded: http://myrepo.com/repo/org/mortbay/jetty/jetty-parent/7/jetty-parent-7.pom (13 KB at 1299.8 KB/sec)
Downloading: http://myrepo.com/repo/org/mortbay/jetty/jetty/6.1.14/jetty-6.1.14.pom
Downloaded: http://myrepo.com/repo/org/mortbay/jetty/jetty/6.1.14/jetty-6.1.14.pom (5 KB at 707.2 KB/sec)
Downloading: http://myrepo.com/repo/org/mortbay/jetty/jetty-util/6.1.14/jetty-util-6.1.14.pom
Downloaded: http://myrepo.com/repo/org/mortbay/jetty/jetty-util/6.1.14/jetty-util-6.1.14.pom (4 KB at 577.0 KB/sec)
Downloading: http://myrepo.com/repo/org/mortbay/jetty/servlet-api-2.5/6.1.14/servlet-api-2.5-6.1.14.jar
Downloading: http://myrepo.com/repo/org/mortbay/jetty/jetty/6.1.14/jetty-6.1.14.jar
Downloading: http://myrepo.com/repo/org/mortbay/jetty/jetty-util/6.1.14/jetty-util-6.1.14.jar
Downloaded: http://myrepo.com/repo/org/mortbay/jetty/servlet-api-2.5/6.1.14/servlet-api-2.5-6.1.14.jar (130 KB at 2393.8 KB/sec)
Downloaded: http://myrepo.com/repo/org/mortbay/jetty/jetty-util/6.1.14/jetty-util-6.1.14.jar (160 KB at 2950.0 KB/sec)
Downloaded: http://myrepo.com/repo/org/mortbay/jetty/jetty/6.1.14/jetty-6.1.14.jar (505 KB at 6815.2 KB/sec)
[INFO] Logging initialized @3613ms to org.eclipse.jetty.util.log.Slf4jLog
[INFO] Configuring Jetty for project: maventest
[INFO] webAppSourceDirectory/home/my/workspace/maventest/WebContent does not exist. Trying src/main/webapp
[INFO] webAppSourceDirectory /home/my/workspace/maventest/src/main/webapp does not exist. Trying /home/my/workspace/maventest/target/webapp-tmp
[INFO] Reload Mechanic: automatic
[INFO] Classes directory /home/my/workspace/maventest/target/classes does not exist
[INFO] Context path = /
[INFO] Tmp directory = /home/my/workspace/maventest/target/tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = null
[INFO] Webapp directory = /home/my/workspace/maventest/target/webapp-tmp
[INFO] jetty-9.4.6.v20170531
[INFO] Scanning elapsed time=74ms
[INFO] Started ServerConnector@37b57b54{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.354 s
[INFO] Finished at: 2017-07-27T11:05:09+08:00
[INFO] Final Memory: 23M/981M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.4.6.v20170531:run (default-cli) on project maventest: Execution default-cli of goal org.eclipse.jetty:jetty-maven-plugin:9.4.6.v20170531:run failed: An API incompatibility was encountered while executing org.eclipse.jetty:jetty-maven-plugin:9.4.6.v20170531:run: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getJspConfigDescriptor()Ljavax/servlet/descriptor/JspConfigDescriptor;
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.eclipse.jetty:jetty-maven-plugin:9.4.6.v20170531
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-maven-plugin/9.4.6.v20170531/jetty-maven-plugin-9.4.6.v20170531.jar
[ERROR] urls[1] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-io/9.4.6.v20170531/jetty-io-9.4.6.v20170531.jar
[ERROR] urls[2] = file:/home/my/.m2/repository/net/sourceforge/cobertura/cobertura/2.1.1/cobertura-2.1.1.jar
[ERROR] urls[3] = file:/home/my/.m2/repository/org/ow2/asm/asm/5.1/asm-5.1.jar
[ERROR] urls[4] = file:/home/my/.m2/repository/org/ow2/asm/asm-tree/5.0.1/asm-tree-5.0.1.jar
[ERROR] urls[5] = file:/home/my/.m2/repository/org/ow2/asm/asm-commons/5.1/asm-commons-5.1.jar
[ERROR] urls[6] = file:/home/my/.m2/repository/org/ow2/asm/asm-util/5.0.1/asm-util-5.0.1.jar
[ERROR] urls[7] = file:/home/my/.m2/repository/org/ow2/asm/asm-analysis/5.0.1/asm-analysis-5.0.1.jar
[ERROR] urls[8] = file:/home/my/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar
[ERROR] urls[9] = file:/home/my/.m2/repository/jaxen/jaxen/1.1.4/jaxen-1.1.4.jar
[ERROR] urls[10] = file:/home/my/.m2/repository/org/apache/ant/ant/1.8.3/ant-1.8.3.jar
[ERROR] urls[11] = file:/home/my/.m2/repository/org/apache/ant/ant-launcher/1.8.3/ant-launcher-1.8.3.jar
[ERROR] urls[12] = file:/home/my/.m2/repository/org/apache/ant/ant-junit/1.8.3/ant-junit-1.8.3.jar
[ERROR] urls[13] = file:/home/my/.m2/repository/org/mortbay/jetty/servlet-api-2.5/6.1.14/servlet-api-2.5-6.1.14.jar
[ERROR] urls[14] = file:/home/my/.m2/repository/org/mortbay/jetty/jetty/6.1.14/jetty-6.1.14.jar
[ERROR] urls[15] = file:/home/my/.m2/repository/org/mortbay/jetty/jetty-util/6.1.14/jetty-util-6.1.14.jar
[ERROR] urls[16] = file:/usr/lib/jvm/java-8-openjdk-amd64/jre/../lib/tools.jar
[ERROR] urls[17] = file:/home/my/.m2/repository/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar
[ERROR] urls[18] = file:/home/my/.m2/repository/ch/qos/logback/logback-core/1.0.13/logback-core-1.0.13.jar
[ERROR] urls[19] = file:/home/my/.m2/repository/junit/junit/4.12/junit-4.12.jar
[ERROR] urls[20] = file:/home/my/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
[ERROR] urls[21] = file:/home/my/.m2/repository/org/apache/commons/commons-lang3/3.3.2/commons-lang3-3.3.2.jar
[ERROR] urls[22] = file:/home/my/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.1.1/sisu-inject-bean-2.1.1.jar
[ERROR] urls[23] = file:/home/my/.m2/repository/org/sonatype/sisu/sisu-guice/2.9.4/sisu-guice-2.9.4-no_aop.jar
[ERROR] urls[24] = file:/home/my/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar
[ERROR] urls[25] = file:/home/my/.m2/repository/org/sonatype/aether/aether-util/1.11/aether-util-1.11.jar
[ERROR] urls[26] = file:/home/my/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[27] = file:/home/my/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[28] = file:/home/my/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[29] = file:/home/my/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[30] = file:/home/my/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.4/maven-plugin-tools-api-3.4.jar
[ERROR] urls[31] = file:/home/my/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[32] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-util/9.4.6.v20170531/jetty-util-9.4.6.v20170531.jar
[ERROR] urls[33] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-webapp/9.4.6.v20170531/jetty-webapp-9.4.6.v20170531.jar
[ERROR] urls[34] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-xml/9.4.6.v20170531/jetty-xml-9.4.6.v20170531.jar
[ERROR] urls[35] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-servlet/9.4.6.v20170531/jetty-servlet-9.4.6.v20170531.jar
[ERROR] urls[36] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-quickstart/9.4.6.v20170531/jetty-quickstart-9.4.6.v20170531.jar
[ERROR] urls[37] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-jaas/9.4.6.v20170531/jetty-jaas-9.4.6.v20170531.jar
[ERROR] urls[38] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-security/9.4.6.v20170531/jetty-security-9.4.6.v20170531.jar
[ERROR] urls[39] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-plus/9.4.6.v20170531/jetty-plus-9.4.6.v20170531.jar
[ERROR] urls[40] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-jndi/9.4.6.v20170531/jetty-jndi-9.4.6.v20170531.jar
[ERROR] urls[41] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-server/9.4.6.v20170531/jetty-server-9.4.6.v20170531.jar
[ERROR] urls[42] = file:/home/my/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar
[ERROR] urls[43] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-http/9.4.6.v20170531/jetty-http-9.4.6.v20170531.jar
[ERROR] urls[44] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-jmx/9.4.6.v20170531/jetty-jmx-9.4.6.v20170531.jar
[ERROR] urls[45] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-annotations/9.4.6.v20170531/jetty-annotations-9.4.6.v20170531.jar
[ERROR] urls[46] = file:/home/my/.m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar
[ERROR] urls[47] = file:/home/my/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-server-impl/9.4.6.v20170531/javax-websocket-server-impl-9.4.6.v20170531.jar
[ERROR] urls[48] = file:/home/my/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-client-impl/9.4.6.v20170531/javax-websocket-client-impl-9.4.6.v20170531.jar
[ERROR] urls[49] = file:/home/my/.m2/repository/javax/websocket/javax.websocket-api/1.0/javax.websocket-api-1.0.jar
[ERROR] urls[50] = file:/home/my/.m2/repository/org/eclipse/jetty/websocket/websocket-server/9.4.6.v20170531/websocket-server-9.4.6.v20170531.jar
[ERROR] urls[51] = file:/home/my/.m2/repository/org/eclipse/jetty/websocket/websocket-common/9.4.6.v20170531/websocket-common-9.4.6.v20170531.jar
[ERROR] urls[52] = file:/home/my/.m2/repository/org/eclipse/jetty/websocket/websocket-api/9.4.6.v20170531/websocket-api-9.4.6.v20170531.jar
[ERROR] urls[53] = file:/home/my/.m2/repository/org/eclipse/jetty/websocket/websocket-client/9.4.6.v20170531/websocket-client-9.4.6.v20170531.jar
[ERROR] urls[54] = file:/home/my/.m2/repository/org/eclipse/jetty/jetty-client/9.4.6.v20170531/jetty-client-9.4.6.v20170531.jar
[ERROR] urls[55] = file:/home/my/.m2/repository/org/eclipse/jetty/websocket/websocket-servlet/9.4.6.v20170531/websocket-servlet-9.4.6.v20170531.jar
[ERROR] urls[56] = file:/home/my/.m2/repository/org/eclipse/jetty/apache-jsp/9.4.6.v20170531/apache-jsp-9.4.6.v20170531.jar
[ERROR] urls[57] = file:/home/my/.m2/repository/org/eclipse/jetty/toolchain/jetty-schemas/3.1/jetty-schemas-3.1.jar
[ERROR] urls[58] = file:/home/my/.m2/repository/org/mortbay/jasper/apache-jsp/8.5.9.1/apache-jsp-8.5.9.1.jar
[ERROR] urls[59] = file:/home/my/.m2/repository/org/mortbay/jasper/apache-el/8.5.9.1/apache-el-8.5.9.1.jar
[ERROR] urls[60] = file:/home/my/.m2/repository/org/eclipse/jdt/core/compiler/ecj/4.4.2/ecj-4.4.2.jar
[ERROR] urls[61] = file:/home/my/.m2/repository/org/eclipse/jetty/apache-jstl/9.4.6.v20170531/apache-jstl-9.4.6.v20170531.jar
[ERROR] urls[62] = file:/home/my/.m2/repository/org/apache/taglibs/taglibs-standard-spec/1.2.5/taglibs-standard-spec-1.2.5.jar
[ERROR] urls[63] = file:/home/my/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar
[ERROR] urls[64] = file:/home/my/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] -> [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/PluginContainerException
那么为什么这个项目的pom.xml依赖于jetty 6的库,或者如何检查插件的依赖?
答案 0 :(得分:0)
我通过
解决了我的问题 <dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>2.1.1</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>org.mortbay.jetty</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>