Extending Spring Initializr: From start.spring.io to Alibaba's start.aliyun.com
This article explains how Alibaba built start.aliyun.com on top of Spring Initializr, adding component demos, configuration, version management, and custom extensions to streamline Spring Boot project generation for Java developers.
Background
Spring Initializr (start.spring.io) is widely used to bootstrap Spring Boot projects. Alibaba integrated Nacos and Sentinel, but the generated skeleton only contains component coordinates without usage instructions or demo code, forcing developers to search for tutorials and resolve version mismatches.
Alibaba’s Extension (start.aliyun.com)
Alibaba built a bootstrap site on top of Spring Initializr, adding:
Dedicated demo code and configuration samples for each component.
Built‑in documentation to reduce external look‑ups.
Only “addition” steps required from developers; the platform handles component integration.
Multi‑component integration solutions (in development).
Regular synchronization with start.spring.io to stay up‑to‑date.
The implementation reuses the spring-io/initializr core repository and extends it rather than rewriting the generation engine.
Basic Usage
Add the initializr-bom to the Maven dependencyManagement section:
<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>Then include the required modules, e.g. initializr-generator-spring, initializr-version-resolver, and initializr-web.
Configuration (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
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.gradleDefining Dependencies
initializr:
dependencies:
- name: Web
content:
- name: Web
id: web
description: Full‑stack web development with Tomcat and Spring MVC
- name: Spring Boot DevTools
id: devtools
groupId: org.springframework.boot
artifactId: spring-boot-devtools
description: Fast restarts, LiveReload, and enhanced development experience.
- name: Lombok
id: lombok
groupId: org.projectlombok
artifactId: lombok
description: Reduces boilerplate code via annotations.Each dependency can specify groupId, artifactId, description, optional version, and a compatibilityRange (Maven version range syntax) to restrict supported Spring Boot versions.
Version Management with BOMs
Define a BOM under initializr.env.boms and reference it from components via the bom field. Example:
initializr:
env:
boms:
my-api-bom:
groupId: org.acme
artifactId: my-api-dependencies
version: 1.0.0.RELEASE
repositories: my-api-repo-1Component example referencing the BOM:
initializr:
dependencies:
- name: Other
content:
- name: My API
id: my-api
groupId: org.acme
artifactId: my-api
bom: my-api-bomAdvanced Customization
Custom demo code can be generated by implementing ProjectContributor beans and conditionally registering them with @ConditionalOnRequestedDependency:
@Bean
@ConditionalOnRequestedDependency("sca-oss")
public OSSDemosContributor ossContributor() {
return new OSSDemosContributor(description, templateRenderer);
}Demo files are stored as Mustache templates in resources and rendered during generation.
Internal Mechanics
Project generation consists of two phases:
Startup phase : Loads configuration, registers SPI extensions, and creates beans such as InitializrMetadataProvider, TemplateRenderer, and web controllers.
Generation phase : For each request, a fresh ProjectGenerationContext (a child of the main application context) is created. It registers a ProjectDescriptionProvider, then executes a series of ProjectContributor and *Customizer beans to write files, configure build scripts, and add documentation.
Key extension points: ProjectContributor – writes files to the project directory (e.g., Maven POM, source code, resources). *Customizer – modifies the project model before generation (e.g., MainApplicationTypeCustomizer, BuildCustomizer, GitIgnoreCustomizer).
Extensibility is driven by spring.factories entries that register factories for build systems, languages, packaging, and other modules.
References
Spring Initializr documentation:
https://docs.spring.io/initializr/docs/current-SNAPSHOT/reference/html/Spring Initializr source code: https://github.com/spring-io/initializr start.spring.io source code:
https://github.com/spring-io/start.spring.ioAlibaba Cloud Native
We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.
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.
