liveBook · Manning

Spring Boot

As explained in Java Persistence with Spring Data and Hibernate epub

Spring Boot is a framework for building Spring applications with convention-based configuration, auto-configuration, and deployable application support.

Spring Boot provides the application shell for several database-backed Spring projects. A project generated with Spring Initializr supplies a main class, a test class, an initially empty application.properties file, and a Maven pom.xml. Choose starters according to the job: Spring Data JPA or Spring Data JDBC for persistence, and Spring Web plus REST Repositories when repositories need a REST interface. section 4.2 section 15.1 section 16.2

For a MySQL-backed application, complete the generated project in this order:

  • Add the relevant Spring Data starter and MySQL driver to pom.xml. A JPA project uses spring-boot-starter-data-jpa; a JDBC project uses spring-boot-starter-data-jdbc. section 4.2 section 15.1
  • Set the datasource URL and credentials in application.properties. Spring Boot loads this file from the classpath; Maven places src/main/resources there. Replace example credentials for your environment. section 15.1 section 16.2
  • Decide how the schema is initialized. For a MySQL Spring Data JDBC example, spring.sql.init.mode=always makes classpath schema.sql and data.sql run at startup; the shown schema script drops and recreates USERS. section 15.1

A REST-backed persistence application

A Spring Data REST project combines spring-boot-starter-web, spring-boot-starter-data-jpa, spring-boot-starter-data-rest, and the MySQL driver. Its application class uses @SpringBootApplication and SpringApplication.run(...); an ApplicationRunner saves users through a JpaRepository at startup. With server.port=8081, an example request is GET http://localhost:8081/users/1. This setup connects project dependencies, configuration, startup work, and a browser-accessible repository interface. section 16.2

Treat configuration as operational behavior, not just setup. The examples configure SQL visibility, database dialect, and schema creation in application.properties; choosing startup schema recreation or unconditional SQL initialization affects existing data. Parameters can also come from source code or command-line arguments rather than a properties file. For persistence tests, the generated project adds Spring Data JPA, validation, the MySQL driver, and a test starter. section 15.1 section 16.2 section 20.2

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Works through generated files, starters, datasource properties, SQL initialization, and startup code; does not explain Spring Boot internals.
Examples
Uses generated persistence projects, application.properties settings, a schema.sql script, an ApplicationRunner, and a REST GET request.
What it assumes
Assumes familiarity with Java and Maven while showing how to generate project skeletons and add persistence dependencies.
What you can do after
Build it from scratch with Spring Initializr, then configure a MySQL-backed Spring Data application and its startup behavior.
How it connects
Connects Spring Initializr and Maven starters to Spring Data JPA, Spring Data JDBC, Spring Data REST, and MySQL.

Also explained in

Compare how 4 books explain Spring Boot →

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.