哇,这个问题,简直都无力吐槽。。。。。。
首先,描述一下想要干啥,以下讨论的都是windows开发环境:
我要使用模板,用mvn archetype:generate命令构建一个maven工程,很简单的需求对吧,但是我执行了下面这串命令:
mvn archetype:generate -DgroupId=com.itheima -DartifactId=AotuMavenWeb -DarchetypeArtifactId=maven-archetype-webapp -Dversion=0.0.1-snapshot -DinteractiveMode=false
它报错啦!!!!!,错误如下:
PS D:\Project\Java> mvn archetype:generate -DgroupId=com.itheima -DartifactId=AotuMavenWeb -DarchetypeArtifactId=maven-archetype-webapp -Dversion=0.0.1-snapshot -DinteractiveMode=false
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.104 s
[INFO] Finished at: 2022-02-02T09:39:10+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (D:\Project\Java). Please verify you invoked Maven from the correct directory. -> [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/MissingProjectException
好家伙,我要构建一个工程(pom),然后你说没有pom文件,离谱不?然后在网上找了半天,好难找啊,遇到这个问题的不多,然后让我在这个帖子里找到了:
mvn archetype:generate不起作用 - 找不到前缀'archetype'的插件 - 问答 - 云+社区 - 腾讯云
没错,是PowerShell的问题啊,换成cmd就没问题了,后来换了git自带的Git Bash也没问题了。帖子里的修改java路径我没试,我想一般人不愿意修改自己的java路径吧。
问题原因很简单,但是很蛋疼,谁能想到是这种问题。
最后吐槽一下,windows真垃圾,珍爱生命,远离Windows