java 您指定的目标需要一个项目来执行,但此目录中没有POM

dxxyhpgq  于 2023-05-05  发布在  Java
关注(0)|答案(3)|浏览(251)

我面临以下例外:
org.apache.maven.lifecycle.MissingProjectException:您指定的目标需要一个项目来执行,但此目录(C:)中没有POM。请验证是否从正确的目录调用了Maven。
控制台日志:

[DEBUG] Reading global settings from C:\Program Files\apache-maven-3.2.5\conf\settings.xml 
[DEBUG] Reading user settings from C:\Users\user_aaa\.m2\settings.xml 
[DEBUG] Using local repository at C:\path\to\local\repo 
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\path\to\local\repo 
[INFO] Scanning for projects... 
[DEBUG] Extension realms for project org.apache.maven:standalone-pom:pom:1: (none) 
[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.078 s 
[INFO] Finished at: 2017-09-12T17:05:08+08:00 
[INFO] Final Memory: 5M/123M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\). Please verify you invoked Maven from the correct directory. -> [Help 1] org.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a project to execute but there is no POM in this directory (C:\). Please verify you invoked Maven from the correct directory.

Maven版本信息:

C:\>mvn -X version 
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-15T01:29:23+08:00) 
Maven home: C:\Program Files\apache-maven-3.2.5 
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_144\jre 
Default locale: en_US, platform encoding: MS950_HKSCS
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "dos"

我需要自己设置pom.xml吗?怎么做在哪里做我是否在Windows中正确安装了Maven?

w1e3prcc

w1e3prcc1#

看起来你执行mvn命令的当前目录不包含pom.xml只要把你当前的目录更改到你的pom所在的位置并在那里执行mvn命令。

7ajki6be

7ajki6be2#

查找maven版本的命令为

mvn -X -version

尽管-X是一个调试选项,在这里是多余的。
如果你想执行一个项目。
我需要自己设置pom.xml吗?怎么做在哪里做
您可以在基于maven的项目的顶层目录中创建一个pom.xml。第一个maven项目示例将在这里进一步帮助您。

qco9c6ql

qco9c6ql3#

1.安装Maven(下载apache-maven-3.9.1-bin.zip)

  1. Ungip apache-maven-3.9.1-bin.zip
    1.设置环境变量export M2_HOME=/Applications/apache-maven-3.9.1 export PATH=$PATH:$M2_HOME/bin
  2. mvn -X -版本
    1.转到pom.xml所在的项目位置
  3. mvn clean [INFO]构建成功
  4. mvn compile [INFO]构建成功
  5. mvn试验

相关问题