maven工程里编译运行main函数出错:“ You must specify a valid lifecycle phase or a goal in the format”
来源:互联网 发布:淘宝详情页主图尺寸 编辑:程序博客网 时间:2024/06/08 15:44
命令行编译Maven工程时碰到如下错误,先记录下解决方案:
***************************************************************************************************************************************************************************************
。。。
[ERROR] Unknown lifecycle phase "/home/tucson/Projects/kafkaGuideTest/target/Getting-Started-0.0.1-SNAPSHOT.jar". 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, p rocess-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/LifecyclePhaseNotFoundException
...
[INFO] ------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------
[INFO] Total time: 2.436s
[INFO] Finished at: Tue Jan 20 10:09:13 CST 2015
[INFO] Final Memory: 10M/101M
[INFO] ------------------------------------------------------------
[WARNING] The requested profile "dev" could not be activated becaus
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin: exception occured while executing the Java class. backtype/storm/spo
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven wit
[ERROR] Re-run Maven using the -X switch to enable full debug loggi
[ERROR]
[ERROR] For more information about the errors and possible solution
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/M
***************************************************************************************************************************************************************************************
解决方案:
在maven工程里运行Java main方法是通过Maven的exec插件以命令行方式运行。
在运行前,你需要先编译代码,记住exec:java不会自动为你编译代码,你需要先编译。
mvn compile编译完之后如下命令运行你的class
mvn exec:java -Dexec.mainClass="com.vineetmanohar.module.Main"如果需要添加参数
mvn exec:java -Dexec.mainClass="com.vineetmanohar.module.Main" -Dexec.args="arg0 arg1 arg2"附注:
compile:默认使用该依赖,对编译,测试,运行三种classpath 都有效
test: 只对测试时有效,如junit (在dependency中,当<scope>为test时,说明该依赖包只会加入到测试代码中去)
provided:在运行时无效,对编译和测试有效,如servlet-api
runtime:如JDBC,对测试和运行有效,在编译时无效
2.一个对传递性依赖的排除
示例2.1:表示虽然依赖project-a,但是不想依赖a所依赖的b。
<groupId>org.sonatype.mavenbook</groupId>
<artifactId>project-a</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<groupId>org.sonatype.mavenbook</groupId>
<artifactId>project-b</artifactId>
</exclusion>
</exclusions>
</dependency>
示例2.2:排除一个依赖, 添加另外一个依赖:
<dependency><groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.5.ga</version>
<exclusions>
<exclusion>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<version>1.1</version>
</dependency>
使用排除依赖, 一般是一个传递依赖在编译的时候需要, 但是在实际运行环境不需要的时候
- maven工程里编译运行main函数出错:“ You must specify a valid lifecycle phase or a goal in the format”
- Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal
- Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal
- No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in t
- Eclipse集成Maven打包时报错:Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goa
- No goals have been specified for this build. You must specify a valid li fecycle phase or a goal in
- Maven工程报错:No goals have been specified for this build. You must specify a valid lifecycle phase or a
- 错误LifecyclePhaseNotFoundException,Unknown lifecycle phase "mvn". You must specify a valid lifecycle
- LifecyclePhaseNotFoundException,Unknown lifecycle phase "mvn". You must specify a valid lifecycle
- 异常:Unknown lifecycle phase "mvn". You must specify a valid lifecycle
- 错误LifecyclePhaseNotFoundException,Unknown lifecycle phase "mvn". You must specify a valid lifecycle
- Maven报错 解决方案。ERROR: No goals have been specified for this build. You must specify a valid lifecycle
- Maven不让编译: No goals have been specified for this build. You must specify a valid lifecy
- you must specify a way to create the tab indicator.
- ValueError: cannot index a corpus with zero features (you must specify either `num_features` or a no
- mvn-lifecycle、phase、goal
- You must specify the value attribute or nested tag
- Caused by: java.lang.IllegalArgumentException: you must specify a way to create the tab indicator.
- 信息在网络中的漫游(四)
- 限制UITextField输入字数
- smtp 中间人 智能主机 中继 代理 监控服务器
- Android SDK镜像的介绍使用
- 内容提供者ContentProvider共享数据,监控短信,操作联系人
- maven工程里编译运行main函数出错:“ You must specify a valid lifecycle phase or a goal in the format”
- 能早睡的程序员,不简单
- POJ 3621--Sightseeing Cows(0-1规划求最大密度)
- Android学习笔记之Android项目的目录结构
- TCP长连接与短连接的区别
- C#中如何使用TimeSpan
- u盘安装Windows系统
- 如何选购高性能的镜像交换机
- BootChess in just 487 bytes