20

我是 Maven 和骆驼的新手。

我尝试执行骆驼书中的示例。运行以下命令时出现此错误。

命令:

mvn test -Dtest= SpringTransformMethodTest

错误:

[ERROR] Unknown lifecycle phase "SpringTransformMethodTest". You must specify a valid lifecycle phase or a goal in the f
ormat <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle ph
ases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, proce
ss-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, ver
ify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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.`
4

6 回答 6

29

和之间可能有空格。然后将其解释为 2 项而不是 1 项。-Dtest=SpringTransformMethodTest

于 2013-09-09T12:52:26.293 回答
18

如果参数名称不是单个“单词”,您可能还需要将其括在引号中,如下所示:

mvn gatling:test -D"gatling.simulationClass"="my.package.PostmanSimulation"
于 2019-02-21T09:42:05.547 回答
13

这个错误也发生在我身上。我正在运行这个命令,它的参数之间没有空格 mvn install 它的值。

使用此命令:

> mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file 
-Dfile=C:\Users\arcones\Desktop\ojdbc7.jar 
-DgroupId=com.oracle 
-DartifactId=ojdbc7 
-Dversion=12.1.0.1 
-Dpackaging=jar 
-DlocalRepositoryPath=lib

我收到了这个错误:

[错误] 未知的生命周期阶段“.oracle”。您必须以 : 或 :[:]: 格式指定有效的生命周期阶段或目标。可用的生命周期阶段有:验证、初始化、生成源、流程源、生成资源、流程资源、编译、流程类、生成测试源、流程测试源、生成测试资源、过程测试资源、测试编译、过程测试类 es、测试、准备包、包、集成前测试、集成测试、集成后测试、验证、安装、部署、预清洁,清洁,清洁后,现场前,现场,现场后,现场部署。-> [帮助 1]

通过为每个值添加双引号解决了该问题:

> mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file 
-Dfile="C:\Users\arcones\Desktop\ojdbc7.jar" 
-DgroupId="com.oracle"
-DartifactId="ojdbc7"
-Dversion="12.1.0.1"
-Dpackaging="jar" 
-DlocalRepositoryPath="lib"

[信息] 构建成功

于 2016-06-03T07:36:46.707 回答
1

我也得到了错误

[ERROR] Unknown lifecycle phase "pacakge". 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-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

你可能会输入错误的命令将'pacakge'更改为'package'

于 2020-06-12T05:57:27.813 回答
0

问题还在于未修剪的字符串,不仅包含空格。

要重现,请使用未修剪的字符串变量来传递参数

toto=" -DskipTests "
mvn install ${toto}  
[ERROR] Unknown lifecycle phase "  -DskipTests "

要修复它,请使用简单xargs的来修剪 arguments 变量。

toto=" -DskipTests "
toto=$(echo "$toto"|xargs)            
mvn install ${toto} 

也适用于多个参数:

toto="  -DskipTests -DotherVal=1  "

堆栈:Ubuntu20.4 + Mvn3.8.3 + zsh5.8 + oh-my-zsh

于 2021-10-07T20:46:17.107 回答
0

不小心打字:

mvn 包

代替:

mvn包

产量/结果:

[错误] 未知的生命周期阶段“包”。[ ...ETC...]

堆栈:GitBash+Windows10+Maven3.5.4

于 2018-07-10T18:43:50.457 回答