2013-06-12 72 views
0

我有一個使用@Autowired註釋和@ContextConfiguration和@Category註釋的測試類。通過彈簧命令行運行時出錯

該測試在月食期間運行良好。 但是,當我嘗試通過命令行運行它時,它拋出以下錯誤。

[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 25.690s 
[INFO] Finished at: Wed Jun 12 09:56:48 GMT+05:30 2013 
[INFO] Final Memory: 31M/81M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.14.1:integration-test (default) on project OmnitureSeleniumTests: Execution default of goal org.apache.maven.plugins:maven-failsafe-plugin:2.14.1:integration-test failed: There was an error in the forked process 
[ERROR] java.lang.NoSuchMethodError: org.junit.runner.Request.classes(Lorg/junit/runner/Computer;[Ljava/lang/Class;)Lorg/junit/runner/Request; 
[ERROR] at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.createReqestAndRun(JUnitCoreWrapper.java:128) 
[ERROR] at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.executeEager(JUnitCoreWrapper.java:111) 
[ERROR] at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:84) 
[ERROR] at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:138) 
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
[ERROR] at java.lang.reflect.Method.invoke(Method.java:597) 
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208) 
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:159) 
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:87) 
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) 
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95) 
[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/PluginExecutionException 

我使用JUnit 4.8.2和 Maven的故障保護,插件:2.14.1

回答

0

從Eclipse中運行Maven的時候VS命令行可能有很多配置/環境的差異:

  1. 該maven版本/路徑。在Eclipse中,實際的maven二進制文件可以通過首選項默認/顯式設置,而在命令行中,操作系統會選擇PATH env var中可用的第一個。使用mvn -version檢查maven版本
  2. Maven用戶/全局settings.xml。當通過命令行運行時,通常使用〜/ .m2/settings.xml,但是可以在Eclipse首選項上顯式覆蓋此選項。
  3. Maven本地存儲庫高速緩存。如果您在1和/或2上有差異,您可能會得到不同的本地存儲庫緩存。如果針對不同的本地存儲庫緩存執行不正確的工件分發,可能會導致構建失敗。
  4. Eclipse maven可能會使用與您的命令行不同版本的JVM。
0

我已經改變Maven的故障保護,插件的版本到2.6,現在運行良好直通命令行:)

相關問題