DataSource configuration in Boot
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
connect Shop to PostgreSQL with properties only.
Planned topics
- Add the
spring-boot-starter-jdbcdependency and the PostgreSQL driver. - Set
spring.datasource.url,username, andpasswordinapplication.yml; Boot builds a HikariCP pool. - Secrets come from environment variables, not from the file in Git.
- Pool size is configurable (
spring.datasource.hikari.maximum-pool-size); defaults are fine to start. - Boot creates
JdbcTemplateandJdbcClientbeans for you.
Draft outline details
Demonstration
spring:
datasource:
url: jdbc:postgresql://localhost:5432/shop
username: ${DB_USER}
password: ${DB_PASSWORD}Check your understanding
Which pool does Boot use by default?
Show answer
HikariCP.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.