我在我的大学开了一个简单的(空白)项目来检查Maven / Jetty是否正常工作。
虽然我已经安装了Maven 3.1.1并且在我运行项目时它在mvn -version
下运行但是我遇到了很长的错误:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.949s
[INFO] Finished at: Tue Jan 14 20:43:18 CET 2014
[INFO] Final Memory: 13M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.1.0.v20131115:run (default-cli) on project java2: Execution default-cli of goal org.eclipse.jetty:jetty-maven-plugin:9.1.0.v20131115:run failed: Unable to load the mojo 'run' in the plugin 'org.eclipse.jetty:jetty-maven-plugin:9.1.0.v20131115' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/eclipse/jetty/maven/plugin/JettyRunMojo : Unsupported major.minor version 51.0
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.eclipse.jetty:jetty-maven-plugin:9.1.0.v20131115
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-maven-plugin/9.1.0.v20131115/jetty-maven-plugin-9.1.0.v20131115.jar
[ERROR] urls[1] = file:/Users/Fengson/.m2/repository/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar
[ERROR] urls[2] = file:/Users/Fengson/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar
[ERROR] urls[3] = file:/Users/Fengson/.m2/repository/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4.jar
[ERROR] urls[4] = file:/Users/Fengson/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.1.1/sisu-inject-bean-2.1.1.jar
[ERROR] urls[5] = file:/Users/Fengson/.m2/repository/org/sonatype/sisu/sisu-guice/2.9.4/sisu-guice-2.9.4-no_aop.jar
[ERROR] urls[6] = file:/Users/Fengson/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar
[ERROR] urls[7] = file:/Users/Fengson/.m2/repository/org/sonatype/aether/aether-util/1.11/aether-util-1.11.jar
[ERROR] urls[8] = file:/Users/Fengson/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[9] = file:/Users/Fengson/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[10] = file:/Users/Fengson/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[11] = file:/Users/Fengson/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[12] = file:/Users/Fengson/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.1/maven-plugin-tools-api-3.1.jar
[ERROR] urls[13] = file:/Users/Fengson/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[14] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-util/9.1.0.v20131115/jetty-util-9.1.0.v20131115.jar
[ERROR] urls[15] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-webapp/9.1.0.v20131115/jetty-webapp-9.1.0.v20131115.jar
[ERROR] urls[16] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-xml/9.1.0.v20131115/jetty-xml-9.1.0.v20131115.jar
[ERROR] urls[17] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-servlet/9.1.0.v20131115/jetty-servlet-9.1.0.v20131115.jar
[ERROR] urls[18] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-jaas/9.1.0.v20131115/jetty-jaas-9.1.0.v20131115.jar
[ERROR] urls[19] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-security/9.1.0.v20131115/jetty-security-9.1.0.v20131115.jar
[ERROR] urls[20] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-plus/9.1.0.v20131115/jetty-plus-9.1.0.v20131115.jar
[ERROR] urls[21] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-jndi/9.1.0.v20131115/jetty-jndi-9.1.0.v20131115.jar
[ERROR] urls[22] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-server/9.1.0.v20131115/jetty-server-9.1.0.v20131115.jar
[ERROR] urls[23] = file:/Users/Fengson/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar
[ERROR] urls[24] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-http/9.1.0.v20131115/jetty-http-9.1.0.v20131115.jar
[ERROR] urls[25] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-io/9.1.0.v20131115/jetty-io-9.1.0.v20131115.jar
[ERROR] urls[26] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-jmx/9.1.0.v20131115/jetty-jmx-9.1.0.v20131115.jar
[ERROR] urls[27] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-annotations/9.1.0.v20131115/jetty-annotations-9.1.0.v20131115.jar
[ERROR] urls[28] = file:/Users/Fengson/.m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar
[ERROR] urls[29] = file:/Users/Fengson/.m2/repository/org/ow2/asm/asm/4.1/asm-4.1.jar
[ERROR] urls[30] = file:/Users/Fengson/.m2/repository/org/ow2/asm/asm-commons/4.1/asm-commons-4.1.jar
[ERROR] urls[31] = file:/Users/Fengson/.m2/repository/org/ow2/asm/asm-tree/4.1/asm-tree-4.1.jar
[ERROR] urls[32] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-server-impl/9.1.0.v20131115/javax-websocket-server-impl-9.1.0.v20131115.jar
[ERROR] urls[33] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-client-impl/9.1.0.v20131115/javax-websocket-client-impl-9.1.0.v20131115.jar
[ERROR] urls[34] = file:/Users/Fengson/.m2/repository/javax/websocket/javax.websocket-api/1.0/javax.websocket-api-1.0.jar
[ERROR] urls[35] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/websocket/websocket-server/9.1.0.v20131115/websocket-server-9.1.0.v20131115.jar
[ERROR] urls[36] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/websocket/websocket-common/9.1.0.v20131115/websocket-common-9.1.0.v20131115.jar
[ERROR] urls[37] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/websocket/websocket-api/9.1.0.v20131115/websocket-api-9.1.0.v20131115.jar
[ERROR] urls[38] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/websocket/websocket-client/9.1.0.v20131115/websocket-client-9.1.0.v20131115.jar
[ERROR] urls[39] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/websocket/websocket-servlet/9.1.0.v20131115/websocket-servlet-9.1.0.v20131115.jar
[ERROR] urls[40] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/jetty-jsp/9.1.0.v20131115/jetty-jsp-9.1.0.v20131115.jar
[ERROR] urls[41] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/toolchain/jetty-schemas/3.1.M0/jetty-schemas-3.1.M0.jar
[ERROR] urls[42] = file:/Users/Fengson/.m2/repository/javax/servlet/jsp/javax.servlet.jsp-api/2.3.1/javax.servlet.jsp-api-2.3.1.jar
[ERROR] urls[43] = file:/Users/Fengson/.m2/repository/org/glassfish/web/javax.servlet.jsp/2.3.2/javax.servlet.jsp-2.3.2.jar
[ERROR] urls[44] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/orbit/javax.servlet.jsp.jstl/1.2.0.v201105211821/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar
[ERROR] urls[45] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/orbit/org.apache.taglibs.standard.glassfish/1.2.0.v201112081803/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar
[ERROR] urls[46] = file:/Users/Fengson/.m2/repository/org/glassfish/javax.el/3.0.0/javax.el-3.0.0.jar
[ERROR] urls[47] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/orbit/org.eclipse.jdt.core/3.8.2.v20130121/org.eclipse.jdt.core-3.8.2.v20130121.jar
[ERROR] urls[48] = file:/Users/Fengson/.m2/repository/org/eclipse/jetty/orbit/javax.activation/1.1.0.v201105071233/javax.activation-1.1.0.v201105071233.jar
[ERROR] urls[49] = file:/Users/Fengson/.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
我错过了什么?
答案 0 :(得分:3)
版本51对应于以下消息中的JDK 7:
org/eclipse/jetty/maven/plugin/JettyRunMojo: Unsupported major.minor version 51.0
似乎Jetty 9是使用JDK 7构建的,源设置为1.7
。您可以尝试安装JDK 7来运行它。
答案 1 :(得分:2)
好的,我让它运转了。似乎Maven正在使用Java 1.6而不是1.7。 我打开终端并做了:
cd /usr/local/Cellar/maven/3.1.1/libexec/bin/
然后编辑了mvn
文件:
open -e mvn
并在开头添加了这个:
export JAVA_HOME=$(/usr/libexec/java_home)
是OSX中的默认Java目录。 之后它运作得很好。
我没有看到Andrey Chaschev回答,但它似乎指出同一个问题,所以我会接受这个答案。谢谢,安德烈!