Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法在终端中运行mvn测试_Java_Maven_Selenium_Intellij Idea - Fatal编程技术网

Java 无法在终端中运行mvn测试

Java 无法在终端中运行mvn测试,java,maven,selenium,intellij-idea,Java,Maven,Selenium,Intellij Idea,我正在使用Intellij和Maven为Selenium Webdriver做一个hello world,我能够让项目在Intellij中成功运行测试 但当我转到终端中的项目根目录时,它失败了。我试图查看过去的问题,但找不到解决此问题的方法 我的终端: [INFO] Scanning for projects... [INFO] [INFO] ----

我正在使用Intellij和Maven为Selenium Webdriver做一个hello world,我能够让项目在Intellij中成功运行测试

但当我转到终端中的项目根目录时,它失败了。我试图查看过去的问题,但找不到解决此问题的方法

我的终端:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building myFirstWebDriverTest 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myFirstWebDriverTest ---
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myFirstWebDriverTest ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ myFirstWebDriverTest ---
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/FinalTrigger/Development/myFirstWebDriverTest/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ myFirstWebDriverTest ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ myFirstWebDriverTest ---
[INFO] Surefire report directory: /Users/FinalTrigger/Development/myFirstWebDriverTest/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2484)
    at java.lang.Class.getMethod0(Class.java:2727)
    at java.lang.Class.getMethod(Class.java:1639)
    at org.apache.maven.surefire.util.ReflectionUtils.tryGetMethod(ReflectionUtils.java:57)
    at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isSuiteOnly(JUnit3TestChecker.java:64)
    at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isValidJUnit3Test(JUnit3TestChecker.java:59)
    at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.accept(JUnit3TestChecker.java:54)
    at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.accept(JUnit4TestChecker.java:51)
    at org.apache.maven.surefire.util.DefaultScanResult.applyFilter(DefaultScanResult.java:97)
    at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:194)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:92)
    ... 9 more

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.326 s
[INFO] Finished at: 2015-09-16T16:05:08-04:00
[INFO] Final Memory: 8M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project myFirstWebDriverTest: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? -> [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/PluginExecutionException

任何帮助都会很好。

根本问题是

原因:java.lang.UnsupportedClassVersionError:org/openqa/selenium/WebDriver:Unsupported major.minor版本51.0

这意味着您正试图使用一个用51类版本构建的JAR,也就是说,它是为Java7构建的


您使用的java(通常由
$java\u HOME
定义)似乎是早期版本。只需确保安装Java 7或更高版本,并将
$Java_HOME
指向它,您就可以了。

IntelliJ中的JDK集可能与Java_HOME环境变量不同。检查mvn-version以查看它使用的是哪个java版本,并将其与IntelliJ中项目设置中的版本进行比较

您有哪个java版本?您应该至少使用java 7@Natalia java version“1.7.0_79”java(TM)SE运行时环境(build 1.7.0_79-b15)java HotSpot(TM)64位服务器VM(build 24.79-b02,混合模式)Apache Maven 3.2.5(12a6b3acb947671f09b81f49094c53f426d8cea1;2014-12-14T12:29:23-05:00)Maven主页:/usr/local/Cell/Maven/3.2.5/libexec java version:1.6.0,供应商:Apple Inc.Java home:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/home默认语言环境:en_US,平台编码:MacRoman操作系统名称:“mac OS x”,版本:“10.10.5”,arch:“x86_64”,系列:“mac”如何更改maven使用的版本?工作正常。我只需要更改mvn使用的版本