Why does Maven ask for a pom.xml when generating a new project?
Asked by
56 garden tiles
I'm new to Java and am trying to create my first Maven project. Maven is installed and available on my PATH. I created an empty folder on my desktop where I want the project to be generated, then opened Windows Command Prompt in that folder and ran: `mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.5 -DinteractiveMode=false`. Maven reports that a pom.xml file is required, even though I'm trying to generate the project that should contain the pom.xml. What am I doing wrong?
Answers
You donโt need an existing pom.xml to run the archetype generator. Make sure youโre using the command exactly as one line in Command Prompt, and that Maven itself is working with `mvn -version`. You can also call the archetype plugin explicitly, which avoids Maven misinterpreting the goal: `mvn org.apache.maven.plugins:maven-archetype-plugin:3.3.0:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.5 -DinteractiveMode=false`. Run it from the empty parent folder; Maven should create a `my-app` directory containing the pom.xml and source folders.
Reply to this answer
Add your answer
Answers are reviewed before publication.
rebound+angle: Since this is Windows Command Prompt, dots in `com.mycompany.app` are fine. The shell-splitting issue mainly applies to other shells, so keep the entire command on one line and donโt add extra punctuation around the options.