7

我尝试在 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
4

3 回答 3

21

Maven 是一个构建工具,但不像ant没有“默认”目标。所以当你跑

 mvn

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

 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)
于 2012-11-28T14:00:35.637 回答
7

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

在此处输入图像描述

于 2015-10-22T20:49:08.523 回答
3

您必须指定构建目标,例如compileinstall。检查您的 Eclipse 启动配置。

于 2012-11-28T14:00:17.110 回答