Backend Development 9 min read

Creating a Custom Maven Archetype Scaffold for Spring Boot Projects

This guide walks through building a reusable Maven archetype scaffold from a Spring Boot template, covering template preparation, Maven configuration, archetype generation, publishing to a repository, and using the scaffold to quickly create new backend projects.

JD Tech
JD Tech
JD Tech
Creating a Custom Maven Archetype Scaffold for Spring Boot Projects

This article explains how to create a custom Maven archetype scaffold from an existing Spring Boot project, enabling rapid generation of new backend services.

1. What is a scaffold? A scaffold is a project template that bundles common configurations (e.g., Spring Boot, MyBatis‑Plus, Redis, Logback, Hutool, Swagger‑UI) to accelerate project initialization.

2. Why use a scaffold? In micro‑service architectures, repeatedly creating similar services leads to duplicated effort and errors; a scaffold automates the creation of boilerplate code, persistence layers, logging, exception handling, and permission control.

3. Creating the scaffold

3.1 Write the project template – either build your own or start from a ready Spring Boot template that already includes the desired dependencies.

3.2 Generate the archetype – run one of the following Maven commands in the project directory:

mvn archetype:create-from-project

or

cd D:\spring-stagging
mvn archetype:create-from-project

The command produces an archetype project structure (see the generated diagram in the original article).

3.3 Publish the archetype – configure distributionManagement in the pom.xml and deploy to your artifact repository (e.g., Artifactory). Example repository configuration:

xxx-central
libs-releases-local
http://artifactory.66.com/libs-releases-local

xxx-snapshots
libs-snapshot-local
http://artifactory.66.com/libs-snapshots-local

The GAV coordinates of the archetype are defined in the POM:

org.springframework.boot.demo
spring-boot-stage-demo-archetype
0.0.1‑SNAPSHOT
maven-archetype

3.4 Configure the archetype GAV – set the groupId, artifactId, and version that will be used when generating new projects.

3.5 Configure Maven – ensure the Maven settings on all developer machines point to the same repository to avoid resolution issues.

4. Using the scaffold to create a new project – after publishing, invoke Maven with the configured GAV to generate a fresh project, then adjust the artifactId as needed.

5. References – the article links to the official Maven Archetype Plugin documentation and several related technical articles.

JavaBackend DevelopmentmavenSpring BootArchetypescaffolding
JD Tech
Written by

JD Tech

Official JD technology sharing platform. All the cutting‑edge JD tech, innovative insights, and open‑source solutions you’re looking for, all in one place.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.