Creating an Initial Spring Project

Spring Initializr

Spring Initializr is a web service that creates an initial Spring Boot project according to the selected conditions. If you specify project settings and the Spring projects to use in the web UI, you can easily start developing a Spring Boot project.

Spring Initializr with curl

When you need to scaffold or build projects repeatedly for Spring verification and similar work, using the web UI can be cumbersome. Therefore, this section uses curl to access the Spring Initializr API and create an initial project.

% curl https://start.spring.io/
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
:: Spring Initializr ::  https://start.spring.io

This service generates quickstart projects that can be easily customized.
Possible customizations include a project's dependencies, Java version, and
build system or build structure. See below for further details.

The services uses a HAL based hypermedia format to expose a set of resources
to interact with. If you access this root resource requesting application/json
as media type the response will contain the following links:
+-----------------+------------------------------------------+
| Rel             | Description                              |
+-----------------+------------------------------------------+
| gradle-build    | Generate a Gradle build file.            |
| gradle-project  | Generate a Gradle based project archive. |
| maven-build     | Generate a Maven pom.xml.                |
| maven-project * | Generate a Maven based project archive. |
+-----------------+------------------------------------------+


The URI templates take a set of parameters to customize the result of a request
to the linked resource.
+-----------------+------------------------------------------+------------------------------+
| Parameter       | Description                              | Default value                |
+-----------------+------------------------------------------+------------------------------+
| applicationName | application name                         | DemoApplication              |
| artifactId      | project coordinates (infer archive name) | demo                         |
| baseDir         | base directory to create in the archive  | no base dir                  |
| bootVersion     | spring boot version                      | 2.7.2                        |
| dependencies    | dependency identifiers (comma-separated) | none                         |
| description     | project description                      | Demo project for Spring Boot |
| groupId         | project coordinates                      | com.example                  |
| javaVersion     | language level                           | 17                           |
| language        | programming language                     | java                         |
| name            | project name (infer application name)    | demo                         |
| packageName     | root package                             | com.example.demo             |
| packaging       | project packaging                        | jar                          |
| type            | project type                             | maven-project                |
| version         | project version                          | 0.0.1-SNAPSHOT               |
+-----------------+------------------------------------------+------------------------------+

... omitted ...

Examples:

To create a default demo.zip:
	$ curl -G https://start.spring.io/starter.zip -o demo.zip

To create a web project using Java 11:
	$ curl -G https://start.spring.io/starter.zip -d dependencies=web \
			-d javaVersion=11 -o demo.zip

To create a web/data-jpa gradle project unpacked:
	$ curl -G https://start.spring.io/starter.tgz -d dependencies=web,data-jpa \
		   -d type=gradle-project -d baseDir=my-dir | tar -xzvf -

To generate a Maven POM with war packaging:
	$ curl -G https://start.spring.io/pom.xml -d packaging=war -o pom.xml