2012-11-28 15 views
2

我嘗試在Eclipse上使用Maven構建我的項目。第一個版本很棒。之後,我得到這個錯誤:在沒有生命週期階段或目標的情況下調用mvn時,Maven構建失敗

  SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
      SLF4J: Defaulting to no-operation (NOP) logger implementation 
      SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
      [INFO] Scanning for projects... 
      [INFO] ------------------------------------------------------------------------ 
      [INFO] BUILD FAILURE 
      [INFO] ------------------------------------------------------------------------ 
      [INFO] Total time: 0.129s 
      [INFO] Finished at: Wed Nov 28 17:51:35 GST 2012 
      [INFO] Final Memory: 2M/121M 
      [INFO] ------------------------------------------------------------------------ 
      [ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [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/NoGoalSpecifiedException 

回答

13

Maven是一個構建工具,但不像ant那裏沒有「默認」目標。所以,當你運行

mvn 

你沒有提供足夠的參數,你需要在哪裏,第二個參數表明其中沿build lifecycle要停止運行像

mvn test 

。然後,Maven將執行每一步,直到您指定的那一步。

一些常見的停靠站

mvn compile (just compile) 
mvn test (compile and run unit tests) 
mvn package (compile, run unit tests, and build the distributable package) 
mvn install (all of the above, and install distributable package into local repository. 
    Install is very useful if you need to build other packages which depend on changes 
    to this package) 
mvn deploy (all of the above, and install package into remote (aka public) repository 
    for sharing with other developers) 
+0

有一個[''(HTTPS://maven.apache。 org/pom.html#BaseBuild_Element),但它並未默認設置。 –

2

你必須指定一個構建目標,例如, 編譯安裝。檢查你的eclipse啓動配置。

3

可以通過命令或月食定下了一個目標:

enter image description here

相關問題