在没有生命周期阶段或目标的情况下调用mvn时,Maven构建失败

时间:2012-11-28 13:58:24

标签: maven

尝试在Eclipse上使用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

3 个答案:

答案 0 :(得分:19)

Maven是一个构建工具,但与ant不同,它没有“默认”目标。所以当你运行

 mvn

您没有提供足够的参数,您需要运行类似

的内容
 mvn test

第二个参数表示您希望停止build lifecycle的位置。然后,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)

答案 1 :(得分:6)

您可以通过命令或eclipse设置目标:

enter image description here

答案 2 :(得分:2)

您必须指定构建目标,例如编译安装。检查你的eclipse启动配置。