liveBook · Manning

Spring Initializr

As explained in Java Persistence with Spring Data and Hibernate epub

Spring Initializr is a web service that generates preconfigured Spring project skeletons from selected project metadata and dependencies.

Spring Initializr at https://start.spring.io/ generates a Spring Boot project archive from project metadata and selected dependencies. Set the group, artifact, and description, select the dependencies, then click Generate and open the downloaded project. The skeleton includes an application class, a test class, an initially empty application.properties file, and a Maven pom.xml. section 4.2

Choose dependencies for the application being built; Initializr records them in pom.xml:

  • For Spring Data JPA with MySQL, select Spring Data JPA and MySQL Driver. The generated Maven file includes spring-boot-starter-data-jpa and mysql-connector-java. section 4.2
  • For Spring Data JDBC with MySQL, select Spring Data JDBC instead of JPA, alongside MySQL Driver. The starter becomes spring-boot-starter-data-jdbc. section 15.1
  • For a Spring Data REST application, select Spring Web, Spring Data JPA, REST Repositories, and MySQL Driver. section 16.2

Generation is a starting point, not finished database configuration. Fill in application.properties for the target database and application behavior, and prepare the required SQL scripts. For example, the Spring Data JDBC setup uses spring.sql.init.mode=always so its classpath initialization scripts run with MySQL rather than only with an embedded database. section 15.1 section 16.2

Listing 16.1 The pom.xml Maven file
Path: Ch16/spring-data-rest/pom.xml
 
<dependency>                                                    #1
    <groupId>org.springframework.boot</groupId>                 #1
    <artifactId>spring-boot-starter-web</artifactId>            #1
</dependency>                                                   #1
<dependency>                                                    #2
    <groupId>org.springframework.boot</groupId>                 #2
    <artifactId>spring-boot-starter-data-jpa</artifactId>       #2
</dependency>                                                   #2
<dependency>                                                    #3
    <groupId>org.springframework.boot</groupId>                 #3
    <artifactId>spring-boot-starter-data-rest</artifactId>      #3
</dependency>                                                   #3
<dependency>                                                    #4
    <groupId>mysql</groupId>                                    #4
    <artifactId>mysql-connector-java</artifactId>               #4
    <scope>runtime</scope>                                      #4
</dependency>                                                   #4

Inspect the generated REST project's pom.xml dependencies to see how the Web, JPA, and REST Repositories selections become Maven starters. section 16.2

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Walks through metadata and dependency selection, generated files, and follow-up configuration; does not examine the generator's internals.
Examples
Shows generated JPA, JDBC, and REST project skeletons with named metadata and dependency selections.
What you can do after
Operate/configure Spring Initializr to generate a Maven-based Spring Boot starter project, then complete its database configuration separately.
How it connects
Connects Spring Boot and Maven dependency management to Spring Data JPA, Spring Data JDBC, Spring Data REST, and MySQL.

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 Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.