Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A Maven archetype turns a working Spring Boot service into a reusable project template. Define the files and properties your team wants generated, package the archetype, then generate services interactively or with a repeatable batch command. Use Spring Initializr for a customizable one-off bootstrap; use an internal archetype when services need consistent organizational conventions.

What a Maven archetype does

Apache Maven describes an archetype as a template for creating Maven projects. The Archetype Plugin can generate a project from an archetype and can also create an archetype from an existing project. That makes a working Spring Boot service a practical starting point: keep its useful structure and conventions, then parameterize the parts that must vary between services.

A generated project is only as consistent as the template you maintain. Decide which dependencies, plugins, and files should be common, and which values—such as Maven coordinates, package name, service name, or optional modules—need to be configurable.

Start with the Spring Boot service you want to generate

Create and verify a normal Spring Boot Maven service before turning it into a template. You can use Spring Initializr to bootstrap this starting project, then adapt it into an archetype. Choose your Java and Spring Boot baselines and establish the dependencies, test setup, and plugin configuration that your team expects every generated service to have.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep fixed conventions fixed in the template. Replace only values that should differ between generated projects with archetype properties. Too few parameters make the template awkward to reuse; too many make it harder to understand and maintain.

Create the archetype project

From the sample service, use the Maven Archetype Plugin’s archetype:create-from-project goal, or create an archetype project directly. An archetype project uses Maven’s maven-archetype packaging. Its resources include metadata and the template files to copy into new projects.

my-service-archetype/
├── pom.xml
└── src/main/resources/
    ├── META-INF/maven/archetype-metadata.xml
    └── archetype-resources/
        ├── pom.xml
        └── src/main/java/__packageInPathFormat__/
            └── Application.java

This is a conceptual layout, not a guarantee that every token or file-set declaration works unchanged across plugin versions. Match the source-path tokens and file sets to the metadata and plugin version you adopt. The built archetype JAR must contain META-INF/maven/archetype-metadata.xml and archetype-resources.

Configure archetype-metadata.xml and template files

The metadata describes properties and the resources the archetype should include. Declare the standard project values—groupId, artifactId, version, and package—and add custom properties only when they change generated output. Configure file sets for source code, resources, tests, and root-level files as appropriate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For Java sources, make sure both the directory path and the package declaration in the generated files resolve to the selected base package. A path such as __packageInPathFormat__ is a template token example; its use must agree with the archetype metadata and the plugin version. Inspect the generated project rather than assuming a token was expanded correctly.

Parameterize the Spring Boot Maven project

Keep the Spring Boot parent or dependency-management arrangement, dependencies, and Maven plugin conventions in the generated pom.xml. Replace service-specific coordinates and other variable values with archetype properties. The Spring Boot Maven Plugin supports executable JAR or WAR packaging, running the application, generating build information, and starting the application before integration tests. The current Spring Boot Maven Plugin guide lists Maven 3.6.3 or later as a prerequisite; check the guide when choosing the supported baseline for your own template.

Keep compatibility policy explicit. The archetype’s supported Java and Spring Boot versions are choices for the template owner, not values Maven can infer for every organization. Version the archetype and document the compatibility you intend generated services to use.

Build, test, and publish the archetype

  1. Build the archetype: Use the archetype packaging lifecycle to produce the JAR, including the metadata and resource tree.
  2. Install it locally while iterating: This lets you generate test projects against the version in your local Maven repository.
  3. Generate a sample project: The Archetype Plugin’s archetype:integration-test goal is intended to generate a sample project from the built archetype. The plugin also provides archetype:update-local-catalog during installation.
  4. Check the generated result: Verify package directories and declarations, resolve dependencies and plugins, build with your stated Maven and Java baseline, run the application using the Spring Boot Maven Plugin, and exercise the integration-test path.
  5. Publish for team use: After validation, publish the versioned archetype to the Maven repository your organization uses and document its coordinates and compatibility policy.

Generate a Spring Boot service from the archetype

Interactive generation

Run mvn archetype:generate and respond to the prompts for the archetype coordinates and new project’s values. This is useful when a person is creating a project manually and wants Maven to ask for missing values.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Batch generation

For scripts or repeatable setup, provide the archetype coordinates and target project values as Maven system properties, then set interactiveMode to false. Replace the illustrative archetype coordinates below with the group ID, artifact ID, and version you actually publish.

mvn archetype:generate 
  -DarchetypeGroupId=com.example.templates 
  -DarchetypeArtifactId=spring-boot-service-archetype 
  -DarchetypeVersion=1.0.0 
  -DgroupId=com.example.orders 
  -DartifactId=orders-service 
  -Dversion=0.0.1-SNAPSHOT 
  -Dpackage=com.example.orders 
  -DinteractiveMode=false

The example uses illustrative coordinates, not a published archetype. Add any custom property your metadata requires as another -Dname=value argument. After generation, inspect the rendered POM and package structure before treating the result as a ready-to-build service.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose between a custom archetype and Spring Initializr

Spring Initializr creates customizable Maven or Gradle starter projects through its web service, CLI, and supported IDE integrations. Its service is continuously updated and may use the latest GA Spring Boot version by default, so verify the selected version when generating. A custom archetype, by contrast, lets a team encode and distribute its own repeatable service conventions.

Decision point Custom Maven archetype Spring Initializr
Main purpose Repeatable organizational template and conventions. Customizable starter project generation.
What can be configured Archetype properties and metadata define the generated files and values. Project metadata, build system, language, packaging, platform version, and dependencies.
How it is distributed Publish to a Maven repository or catalog for team use. Use the hosted service, CLI, or supported IDE integrations.
Who maintains the defaults The template owners version and update generated conventions. The service is continuously updated; check defaults, including the Spring Boot version, when generating.
Best fit Repeated internal service creation where consistency matters. One-off or broadly customizable project bootstrapping.

Choose an archetype when the main need is to reproduce your organization’s baseline reliably across services. Choose Initializr when you want to assemble a starter project from its available options without owning a separate internal template. The two approaches can also be used sequentially: Initializr can supply the initial service that you later shape into your archetype.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.