我尝试使用目标clean jetty:run
来运行Maven项目,但遗憾的是它在编译时出错:
[INFO] Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.351 s
[INFO] Finished at: 2016-02-03T16:19:35+02:00
[INFO] Final Memory: 30M/381M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.mortbay.jetty:jetty-maven- plugin:8.1.7.v20120910:run (default-cli) on project training: Execution default-cli of goal org.mortbay.jetty:jetty-maven-plugin:8.1.7.v20120910:run failed: A required class was missing while executing org.mortbay.jetty:jetty-maven-plugin:8.1.7.v20120910:run: org/springframework/web/context/support/StandardServletEnvironment
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.mortbay.jetty:jetty-maven-plugin:8.1.7.v20120910
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/genvera04/.m2/repository/org/mortbay/jetty/jetty-maven-plugin/8.1.7.v20120910/jetty-maven-plugin-8.1.7.v20120910.jar
[ERROR] urls[1] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-util/8.1.7.v20120910/jetty-util-8.1.7.v20120910.jar
[ERROR] urls[2] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-webapp/8.1.7.v20120910/jetty-webapp-8.1.7.v20120910.jar
[ERROR] urls[3] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-xml/8.1.7.v20120910/jetty-xml-8.1.7.v20120910.jar
[ERROR] urls[4] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-servlet/8.1.7.v20120910/jetty-servlet-8.1.7.v20120910.jar
[ERROR] urls[5] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-security/8.1.7.v20120910/jetty-security-8.1.7.v20120910.jar
[ERROR] urls[6] = file:/Users/genvera04/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.1.1/sisu-inject-bean-2.1.1.jar
[ERROR] urls[7] = file:/Users/genvera04/.m2/repository/org/sonatype/sisu/sisu-guice/2.9.4/sisu-guice-2.9.4-no_aop.jar
[ERROR] urls[8] = file:/Users/genvera04/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar
[ERROR] urls[9] = file:/Users/genvera04/.m2/repository/org/sonatype/aether/aether-util/1.11/aether-util-1.11.jar
[ERROR] urls[10] = file:/Users/genvera04/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[11] = file:/Users/genvera04/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[12] = file:/Users/genvera04/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[13] = file:/Users/genvera04/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[14] = file:/Users/genvera04/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-tools-api/2.9/maven-plugin-tools-api-2.9.jar
[ERROR] urls[15] = file:/Users/genvera04/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar
[ERROR] urls[16] = file:/Users/genvera04/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar
[ERROR] urls[17] = file:/Users/genvera04/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[18] = file:/Users/genvera04/.m2/repository/net/sf/jtidy/jtidy/r938/jtidy-r938.jar
[ERROR] urls[19] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-plus/8.1.7.v20120910/jetty-plus-8.1.7.v20120910.jar
[ERROR] urls[20] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/orbit/javax.transaction/1.1.1.v201105210645/javax.transaction-1.1.1.v201105210645.jar
[ERROR] urls[21] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-jndi/8.1.7.v20120910/jetty-jndi-8.1.7.v20120910.jar
[ERROR] urls[22] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-server/8.1.7.v20120910/jetty-server-8.1.7.v20120910.jar
[ERROR] urls[23] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar
[ERROR] urls[24] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-continuation/8.1.7.v20120910/jetty-continuation-8.1.7.v20120910.jar
[ERROR] urls[25] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/orbit/javax.mail.glassfish/1.4.1.v201005082020/javax.mail.glassfish-1.4.1.v201005082020.jar
[ERROR] urls[26] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/orbit/javax.activation/1.1.0.v201105071233/javax.activation-1.1.0.v201105071233.jar
[ERROR] urls[27] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-jmx/8.1.7.v20120910/jetty-jmx-8.1.7.v20120910.jar
[ERROR] urls[28] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-annotations/8.1.7.v20120910/jetty-annotations-8.1.7.v20120910.jar
[ERROR] urls[29] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/orbit/javax.annotation/1.1.0.v201108011116/javax.annotation-1.1.0.v201108011116.jar
[ERROR] urls[30] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/orbit/org.objectweb.asm/3.1.0.v200803061910/org.objectweb.asm-3.1.0.v200803061910.jar
[ERROR] urls[31] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-websocket/8.1.7.v20120910/jetty-websocket-8.1.7.v20120910.jar
[ERROR] urls[32] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-io/8.1.7.v20120910/jetty-io-8.1.7.v20120910.jar
[ERROR] urls[33] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-http/8.1.7.v20120910/jetty-http-8.1.7.v20120910.jar
[ERROR] urls[34] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/jetty-jsp/8.1.7.v20120910/jetty-jsp-8.1.7.v20120910.jar
[ERROR] urls[35] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/orbit/javax.servlet.jsp/2.2.0.v201112011158/javax.servlet.jsp-2.2.0.v201112011158.jar
[ERROR] urls[36] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/orbit/org.apache.jasper.glassfish/2.2.2.v201112011158/org.apache.jasper.glassfish-2.2.2.v201112011158.jar
[ERROR] urls[37] = file:/Users/genvera04/.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[38] = file:/Users/genvera04/.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[39] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/orbit/javax.el/2.2.0.v201108011116/javax.el-2.2.0.v201108011116.jar
[ERROR] urls[40] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/orbit/com.sun.el/2.2.0.v201108011116/com.sun.el-2.2.0.v201108011116.jar
[ERROR] urls[41] = file:/Users/genvera04/.m2/repository/org/eclipse/jetty/orbit/org.eclipse.jdt.core/3.7.1/org.eclipse.jdt.core-3.7.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.springframework.web.context.support.StandardServletEnvironment
[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文件:
<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/maven-v4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.marakana</groupId>
<artifactId>training</artifactId>
<packaging>war</packaging>
<version>0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<!-- database and connection pool -->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp</artifactId>
<version>0.7.1.RELEASE</version>
<scope>runtime</scope>
</dependency>
<!-- jpa provider -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.7.Final</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
<scope>compile</scope>
</dependency>
<!-- json object mapper -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.10</version>
<scope>compile</scope>
</dependency>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.1.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.0.3.RELEASE</version>
<scope>compile</scope>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.7.v20120910</version>
</plugin>
</plugins>
我已尝试从.m2
删除文件夹,&amp;试图更改属性中的jre,但错误仍然存在。
如何让我的maven项目运行?
答案 0 :(得分:0)
同意评论,对spring依赖项使用相同的版本。
根据错误消息,您的构建缺少此类:
StandardServletEnvironment是在Spring 3.1中引入的,因此它不包含在您使用的spring-web 3.0.4版本中。
要保持版本清理,请尝试使用pom顶部的变量在整个文件中设置spring版本。像这样
<spring.version>4.0.6.RELEASE</spring.version>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>