maven - Maven 项目在 Eclipse 和命令行中失败
问题描述
我正在尝试在 eclipse 中运行一个简单的 maven 项目。当我以“Maven Clean”运行时给我消息“BUILD SUCCESS”但是当我以“Maven Test”运行我的测试时,它再次显示“BUILD SUCCESS”但不打印“你好世界”来自 Systemprintln。下面是我的课。
import org.testng.annotations.Test;
public class TestHellowWorld {
public void testHellowWorld(){
@Test
System.out.println("hello world");
}
}
I am getting following message:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld_raghav 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld_raghav ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloworld_raghav ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helloworld_raghav ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ helloworld_raghav ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ helloworld_raghav ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.536 s
[INFO] Finished at: 2020-04-17T23:13:06-04:00
[INFO] Final Memory: 9M/245M
Now if I try to run this project through command line,build failed with the following message;
C:\Users\tarishah\workspace\helloworld_tarishah>mvn -clean
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< helloworld_raghav:helloworld_raghav >-----------------
[INFO] Building helloworld_raghav 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.164 s
[INFO] Finished at: 2020-04-17T23:08:11-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "lean". 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]
[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/LifecyclePhaseNotFoundException
解决方案
Maven 说Unknown lifecycle phase "lean"
这意味着您没有运行mvn test
(正如您在问题中指出的那样),而是类似mvn lean
or mvn lean test
。
推荐阅读
- algorithm - Min Cost Max Flow 算法,尽可能多地关注所有边缘上的流量均等分布
- javascript - TypeError:无法读取未定义的属性(读取“集合”)-Vuejs 和 Firebase
- git - Git - 将非存储库项目与存储库进行比较
- netcdf - NetCDF - 'phony_dim_0'、'phony_dim_1'、'phony_dim_2' 是什么?
- facebook - Facebook Graph API 错误:用户必须在白名单中。代码:3
- transactions - Coinbase API 中汇款端点的 Idem 参数未按预期运行
- python - 使用 Django REST 框架进行批量 POST 时检查记录是否存在
- python - 如何在 tflite 模型中组合数据预处理代码(在 tflite 中集成数据预处理代码)
- java - 当前请求不是 Postman 的多部分请求
- excel - 扩展 Excel 的书面 VBA 脚本