/errors/maven/no-pom-in-this-directory
The goal you specified requires a project to execute but there is no POM in this directory
- tool
- Maven
- exit code
- 1
- versions
- Maven 3.x, Maven 4
- os
- any
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/path). Please verify you invoked Maven from the correct directory. means Maven was asked to run a project goal (compile, test, package, install, dependency:tree...) in a folder that has no pom.xml. Maven does not search parent or child folders. cd into the folder that contains pom.xml, or pass it explicitly with mvn -f path/to/pom.xml package.
Typical output
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/user/work). Please verify you invoked Maven from the correct directory. -> [Help 1]
...
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectExceptionThe path in parentheses is the directory Maven looked in. The Help link names the exception, MissingProjectException.
Fix
ls pom.xml # is it here?
cd backend && mvn package # the project lives in a subfolder
mvn -f backend/pom.xml package # or point to it without changing directoryIn CI and Docker
| Environment | What to set |
|---|---|
| GitHub Actions | working-directory: backend on the step, or mvn -f backend/pom.xml |
| GitLab CI | cd backend in script, or -f backend/pom.xml |
| Jenkins | dir("backend") { sh "mvn package" } |
| Dockerfile | WORKDIR /app, COPY pom.xml . and COPY src ./src before RUN mvn package |
Goals that do not need a project, such as mvn archetype:generate to create one, run anywhere. Multi-module builds are started from the folder of the parent (aggregator) pom.xml; use -pl module-name -am to build one module from there.