Take a long time to create a project using Maven

Today I need to create a project using Maven. The command I use to create project is as below:

mvn archetype:generate -DgroupId=Your.Group.ID -DartifactId=Your.Artifact.ID -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

This tells Maven to create a Java project from the Maven maven-archetype-quickstarttemplate. If you ignore the archetypeArtifactId option, a huge list of the Maven templates will be listed.

However, I found it took a long time to build, actually, it seems stay in a step and didn't response at all. It doesn't make sense. Because Maven is supposed to be a handy tool.

After googling for a while, I found the solution to it. The root cause is when maven generate the project from the archetype, it will need to download a pom file from Maven repository, the pom file is really big(about 5 MB). The pom is :
http://repo.maven.apache.org/maven2/archetype-catalog.xml

The solution:
You can download the above pom directly from above link, and put it into : C:\Users\Administrator\.m2\repository\org\apache\maven\archetype\archetype-catalog\2.4

And then you build the project with -DarchetypeCatalog=local:

mvn archetype:generate -DgroupId=Your.Group.ID -DartifactId=Your.Artifact.ID -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeCatalog=local

Written on 09 November 2016