liveBook · Manning

Spring Initializr

As explained in Spring in Action, Sixth Edition

A service and project-generation tool that creates initial Spring projects from selected metadata, dependencies, and framework versions.

Spring Initializr generates a skeleton Spring Boot project so you can start writing application code instead of creating directories and a build specification by hand. Use it through its website, REST API, command-line options, or IDE integration. section 1.2

To create a project in Spring Tool Suite:

  • Start a new Spring project and enter its general project information. section 1.2.1
  • Choose the Spring Boot version and starter dependencies. For a web application, select Spring Web, Thymeleaf, and Spring Boot DevTools. section 1.2.1 section 1.2.2
  • Click Finish. The wizard downloads the generated project into your workspace and builds it. Its default Initializr address is http://start.spring.io; change the Base Url only if you use another Initializr instance. section 1.2.1

The generated Maven project includes a populated pom.xml, an application bootstrap class, and a test that checks whether the Spring application context loads. The build inherits dependency management from spring-boot-starter-parent, so covered dependencies do not need individual version declarations. section 1.2.2

Listing 1.1 The initial Maven build specification
<?xml version="1.0" encoding="UTF-8"?><project
xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
        https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.3</version>                              #1
    <relativePath />
  </parent>
  <groupId>sia</groupId>
  <artifactId>taco-cloud</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>taco-cloud</name>
  <description>Taco Cloud Example</description>
 
  <properties>
    <java.version>11</java.version>
  </properties>
 
  <dependencies>
    <dependency>                                        #2
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
 
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
 
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <scope>runtime</scope>
      <optional>true</optional>
    </dependency>
 
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>org.junit.vintage</groupId>
          <artifactId>junit-vintage-engine</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
 
  </dependencies>
 
  <build>
    <plugins>
      <plugin>                                          #3
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
 
  <repositories>
    <repository>
      <id>spring-milestones</id>
      <name>Spring Milestones</name>
      <url>https://repo.spring.io/milestone</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>spring-milestones</id>
      <name>Spring Milestones</name>
      <url>https://repo.spring.io/milestone</url>
    </pluginRepository>
  </pluginRepositories>
 
</project>

Inspect the generated pom.xml to see how project metadata, the Spring Boot parent, Java version, and dependencies become a Maven build specification. section 1.2.2

A separate Admin server

To start a Spring Boot Admin server, generate another Spring Boot project and select Spring Boot Admin (Server). Initializr adds the server starter dependency; enabling the server and setting its port are subsequent configuration steps. section 16.1.1

How Spring in Action, Sixth Edition covers it

How deep it goes
Walks through IDE generation and inspects the resulting project; does not detail every supported Initializr entry point.
Examples
Uses a taco-ordering application’s generated Maven project and a separate Spring Boot Admin server project.
What it assumes
Starts project setup without requiring manual creation of directories or a build specification.
What you can do after
Apply it via Spring Tool Suite to generate and import a Spring Boot project with selected dependencies.
How it connects
Connects starter dependencies, Maven dependency management, application bootstrap, baseline testing, and Spring Boot Admin server setup.

Also explained in

Compare how 3 books explain Spring Initializr →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.