Resolving Maven Archetype Generation Issues
When Maven’s archetype plugin hangs during project generation, you can resolve it by specifying archetypeCatalog=internal or local as a command-line or VM option, placing a downloaded archetype-catalog.xml in ~/.m2, or configuring a domestic mirror in settings.xml, after which generation completes in seconds.
In Java development, the Maven archetype plugin can hang or fail when generating a project.
Typical symptom: long wait with log line [INFO] Generating project in Batch mode and possible errors.
Solution 1: Add the parameter archetypeCatalog=internal when creating the Maven project.
Solution 2: Add VM option -DarchetypeCatalog=internal or -DarchetypeCatalog=local in Maven settings (Settings → Build, Execution, Deployment → Build Tools → Maven → Runner → VM Options).
Solution 3: Download or create an archetype-catalog.xml (e.g., via curl http://repo1.maven.org/maven2/archetype-catalog.xml > archetype-catalog.xml ) and place it in the Maven repository directory ~/.m2 or configure its path in /config/settings.xml . Then run archetype:generate -DarchetypeCatalog=local .
Solution 4: Edit Maven's conf/settings.xml to use a domestic mirror, for example:
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>After applying these changes, project generation completes quickly (e.g., 1.146 s).
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.