liveBook · Manning

Application.properties

As explained in Spring Start Here, Second Edition

application.properties is a Spring Boot configuration file that defines application settings as key-value pairs.

application.properties stores Spring Boot settings as key-value pairs. For a database connection, set its location and credentials with spring.datasource properties; Spring Boot uses them to create a DataSource bean. 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

A MySQL example sets the connection URL and credentials, then enables schema.sql initialization with spring.sql.init.mode=always. Avoid storing real production passwords in the file; use a secret vault. section 12.3.1

How Spring Start Here, Second Edition covers it

How deep it goes
Defines connection and initialization properties and explains DataSource creation, while deferring secret-vault details.
Examples
Uses MySQL connection settings, placeholder credentials, schema.sql initialization, and a purchase-table endpoint.
What it assumes
Assumes a database server, database, and matching JDBC driver; contrasts H2's default schema.sql initialization.
What you can do after
Configure a Spring Boot application to connect to MySQL and initialize a database table.
How it connects
Links Spring Boot configuration with DataSource, JDBC, MySQL, and schema.sql initialization.

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.