Maven Archetype : There is no POM in this directory

Some times ago, I encountered a question on StackOverflow that caught my attention. This was about an error when Maven was called with the archetype goal. The message was saying that to use this goal the user had to execute the command from a directory where there was a POM file. I wondered how this could be as, the archetype goal is used to generate this file and all the project structure. Let’s see what was the error.

mavenapacheThe question on StackOverflow was asked here. The user was on Windows and has installed correctly Maven. The user was facing this error after executing the following command.

 The goal you specified requires a project to execute but there is no POM in this directory (D:\maven). Please verify you invoked Maven from the correct directory. -> [Help 1]

First, I thought that the problem could be with the Archetype plugin so I asked him to execute this command :

As it was working, I supposed it didn’t come from Maven but from its use. I looked at the command given by the user and saw that he was calling for an archetype without ArtifactId. I tested the previous command with the user’s groupId and an artifactId found on the MavenRepository Website and it perfectly worked on my Linux.

After some research I discovered this other question where the user had the same problem and solved it by removing the « \ » (backslash) character. It is used in many tutorials to show that the command is continuing over several lines but it HAS to be removed before executing the command. The same error appears on Linux with the « / » (slash) character. As I used it on my blog, I think it is useful to know about this.Then the user had another error. It was coming from the fact that, he let Maven choose the default artifact from the given groupId which is maven-archetype-quickstart. To prevent this error, he had to use options groupId and artifactId or the IteractiveMode.

Finally after correcting his command with an artifactId and no backslash, the user got it working.



Laisser un commentaire