英文:
How to build the project successfully by maven?
问题
我在GitHub上找到了这个JavaFx项目。
我可以运行包含main
方法的HelloJavaFxAndMavenApp
类,它能够正常工作。
然而,当我尝试使用以下命令通过maven构建项目时,它不起作用:
mvn exec:java -Dexec.mainClass=com.zenjava.examples.hellojfxmaven.HelloJavaFxAndMavenApp
它报错如下:
[ERROR] Unknown lifecycle phase "mvn". 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
英文:
I found this JavaFx project in GitHub.
I can run the HelloJavaFxAndMavenApp
class which contains the main
method and it works like a charm.
However, when I try to build the project using maven by the following command it does not work:
mvn exec:java -Dexec.mainClass=com.zenjava.examples.hellojfxmaven.HelloJavaFxAndMavenApp
it complains by:
[ERROR] Unknown lifecycle phase "mvn". 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
答案1
得分: 1
mvn exec:java -Dexec.mainClass=com.zenjava.examples.hellojfxmaven.HelloJavaFxAndMavenApp
在我克隆项目、构建和运行时似乎运行正常。
从错误消息看,似乎存在多余的 mvn
(即,您已经运行了 mvn mvn exec:java -Dexec.mainClass=com.zenjava.examples.hellojfxmaven.HelloJavaFxAndMavenApp
)。删除重复的 mvn
,然后应该没问题。
可能导致这种情况的一个原因是,如果您不是从命令行而是从某个工具/IDE中运行Maven。在这种情况下,该工具本身已经调用了 mvn
,只需要提供参数(即,exec:java -Dexec.mainClass=com.zenjava.examples.hellojfxmaven.HelloJavaFxAndMavenApp
)。
英文:
mvn exec:java -Dexec.mainClass=com.zenjava.examples.hellojfxmaven.HelloJavaFxAndMavenApp
seems to work just fine when I clone the project, build and run it.
From the error message it looks like you have a redundant mvn
there (i.e., you've run mvn mvn exec:java -Dexec.mainClass=com.zenjava.examples.hellojfxmaven.HelloJavaFxAndMavenApp
. Remove the duplicate mvn
and you should be fine.<br/>
One possible cause for this I could think of is if you're not running Maven from the command line, but from some tool/IDE. In this case, the tool itself already calls mvn
and just expects the arguments (i.e., exec:java -Dexec.mainClass=com.zenjava.examples.hellojfxmaven.HelloJavaFxAndMavenApp
).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论