安装maven时没有指定目标的异常

6mzjoqzu  于 2021-07-07  发布在  Java
关注(0)|答案(1)|浏览(388)

看来这是一个重复的挑战,以建立maven,但我也有我自己的挑战,这。。。!我是maven和java的新手,非常感谢您的帮助!
这是我目前在macosv10.15.7上的设置
正如maven所建议的,我首先定义我的javau主页(在osx中不是默认设置的)

cd ~
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/openjdk-12.0.2.jdk/Contents/Home

echo $PATH
/Users/byc/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin

然后我继续下载maven 3.6.3并在 /Users/byc/Downloads/apache-maven-3.6.3 ,运行以下命令

export PATH=/Users/byc/Downloads/apache-maven-3.6.3/bin:$PATH
mvn --verison
-bash: mvn: command not found

当我运行mvn-e时,我得到了以下信息。这是不是意味着maven对 $PATH 合适吗?

mvn -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.059 s
[INFO] Finished at: 2020-12-01T19:03:43Z
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. 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]
org.apache.maven.lifecycle.NoGoalSpecifiedException: No goals have been specified for this build. 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.
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:97)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[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/NoGoalSpecifiedException
uqzxnwby

uqzxnwby1#

有几件事:
我不知道为什么maven文档继续告诉人们 JAVA_HOME . 这是不必要的,前提是 javac (是的, javac ,不知道为什么)在你的道路上(这通常意味着 java 在你的道路上)。源代码证实了这一点。
你拼错了 version 作为 verison 所以你收到了 -bash: mvn: command not found .
您既没有指定maven生命周期阶段,也没有指定插件目标,因此maven不知道该怎么做。

相关问题