The goal you specified requires a project to execute but there is no POM in this directory

The goal you specified requires a project to execute but there is no POM in this directoryMaven项目打包 mvn -U package -DskipTests 时碰过这个错误。

看错误日志提示,我们知道“/Users/anan/ws/BBKTest”这个路径下找不到pom.xml文件,可是我的工程不是在这个路径下,为什么还是报错,所以我就尝试直接进入工程文件夹,执行mvn test,发现可以正常启动maven工程项目了,原来“mvn test”这个命令就是在当前文件夹下找pom.xml文件并执行。

故 Maven项目打包时,必须切换到项目根目录后,执行命令。