Master Spring Initializr: From Basic Setup to Advanced Customization

This article explains how to use Spring Initializr and Alibaba's start.aliyun.com to generate Spring Boot projects, covering basic dependency setup, configuration of packagings, Java versions, languages, project types, advanced features like caching and demo code injection, and the underlying startup and generation phases of the framework.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Master Spring Initializr: From Basic Setup to Advanced Customization

Background

Many developers use start.spring.io to bootstrap Spring Boot projects, but the generated skeletons lack usage demos, requiring extra lookup.

Aliyun Extension

Alibaba launched start.aliyun.com, built on Spring Initializr, adding per‑component demo code, built‑in documentation, and multi‑component integration.

Usage Guide

1. Basic Usage

Introduce the framework via the BOM dependency.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.spring.initializr</groupId>
            <artifactId>initializr-bom</artifactId>
            <version>0.9.0.BUILD-SNAPSHOT</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Configure supported packagings, Java versions, and languages in application.yml:

initializr:
  packagings:
    - name: Jar
      id: jar
      default: true
    - name: War
      id: war
      default: false
  javaVersions:
    - id: 13
      default: false
    - id: 11
      default: false
    - id: 1.8
      name: 8
      default: true
  languages:
    - name: Java
      id: java
      default: true
    - name: Kotlin
      id: kotlin
      default: false
    - name: Groovy
      id: groovy
      default: false

Define project types (Maven/Gradle) and their actions.

initializr:
  types:
    - name: Maven Project
      id: maven-project
      description: Generate a Maven based project archive.
      tags:
        build: maven
        format: project
      default: true
      action: /starter.zip
    - name: Maven POM
      id: maven-build
      description: Generate a Maven pom.xml.
      tags:
        build: maven
        format: build
      default: false
      action: /pom.xml
    - name: Gradle Project
      id: gradle-project
      description: Generate a Gradle based project archive.
      tags:
        build: gradle
        format: project
      default: false
      action: /starter.zip
    - name: Gradle Config
      id: gradle-build
      description: Generate a Gradle build file.
      tags:
        build: gradle
        format: build
      default: false
      action: /build.gradle

2. Advanced Customization

Enable caching to avoid frequent metadata fetches.

<dependency>
  <groupId>javax.cache</groupId>
  <artifactId>cache-api</artifactId>
</dependency>
<dependency>
  <groupId>org.ehcache</groupId>
  <artifactId>ehcache</artifactId>
</dependency>

Add @EnableCaching on the main class.

Provide component‑specific demo code via ProjectContributor implementations and register them in spring.factories.

io.spring.initializr.generator.project.ProjectGenerationConfiguration=\
com.alibaba.alicloud.initializr.extension.dependency.springboot.SpringCloudProjectGenerationConfiguration

Underlying Principles

The framework separates a startup phase (metadata loading, bean registration) from a generation phase (a dedicated ProjectGenerationContext per request). The generation pipeline creates a context, registers a ProjectDescriptionProvider, applies ProjectDescriptionCustomizer s, and finally invokes a series of ProjectContributor s to write files such as pom.xml, source code, resources, and help documents.

Key extension points include ProjectContributor and various *Customizer interfaces (e.g., MainApplicationTypeCustomizer, BuildCustomizer, GitIgnoreCustomizer).

References

https://docs.spring.io/initializr/docs/current-SNAPSHOT/reference/html/

https://github.com/spring-io/initializr

https://github.com/spring-io/start.spring.io

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaSpring BootcustomizationInitializrProject Generation
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

0 followers
Reader feedback

How this landed with the community

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.