liveBook · Manning

Spring Boot

As explained in Spring Start Here, Second Edition

Spring Boot is a Spring ecosystem project that provides convention-based default configuration for Spring applications.

Spring Boot is a Spring ecosystem project that helps create applications faster by providing ready-to-use configuration and tools. It follows convention over configuration: use common defaults, then change the settings your application needs to handle differently. section 7.0 section 7.2.3

A web application needs a servlet container and configuration to route requests. Spring Boot reduces that setup so you can focus on application behavior rather than writing every configuration yourself. section 7.2

Three features make that possible:

  • Project initialization creates an empty but configured application skeleton. section 7.2
  • Dependency starters group compatible dependencies for a particular capability, so you do not have to select each dependency and version separately. section 7.2
  • Autoconfiguration supplies defaults based on the dependencies in the project. You can change defaults that do not fit your needs. section 7.2

Starting a web application

Add the web dependency and start the application. Spring Boot configures a Tomcat servlet container by convention; in this example, it starts on port 8080. Spring Boot also configures Spring MVC components that handle HTTP requests. section 7.2.3 section 7.5

Configuring a data source

To use MySQL instead of H2, change the database dependency and add connection properties in application.properties. Spring Boot uses the spring.datasource properties to create a DataSource bean. Set spring.sql.init.mode to always to run schema.sql for MySQL; H2 runs it by default when the file exists. Do not store production passwords in the properties file. section 12.3.1

Listing 12.12 The connection properties
spring.datasource.url=jdbc:mysql://localhost/spring_start_here?
useLegacyDatetimeCode=false&serverTimezone=UTC #A
 
spring.datasource.username=<dbms username>    #B
spring.datasource.password=<dbms password>    #B
spring.sql.init.mode=always     #C

These properties specify the database location, credentials, and schema initialization setting for the MySQL example. section 12.3.1

How Spring Start Here, Second Edition covers it

How deep it goes
Explains starters and dependency-based autoconfiguration through defaults and configuration changes, without detailing their internal implementation.
Examples
Uses a web application starting Tomcat on port 8080 and a MySQL data source configured through application.properties.
What it assumes
Assumes familiarity with the Spring context and aspects before developing web applications.
What you can do after
Apply it via Spring Boot to start a web application with defaults and configure a data source.
How it connects
Connects Spring Boot with servlet containers, Spring MVC, and data sources.

Also explained in

Compare how 9 books explain Spring Boot →

Related concepts

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