Maven build时报错:

You must specify a valid lifecycle phase or a goal in the format : or :[:]:. 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-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

Eclipse如图提示

Maven build时报错:No goals have been specified for this build_maven


在cmd命令中执行mvn compile 能正常编译成功。

Maven build时报错:No goals have been specified for this build_cmd命令_02


说明程序没有问题。

需要再pom.xml中标签中添加以下值即可。

<build>
<defaultGoal>compile</defaultGoal>
</build>

Maven build时报错:No goals have been specified for this build_maven_03


在Eclipse中重新执行Run as --》 maven build

编译成功。