Demo: replacing the in-memory repository with Spring JDBC
On This Lesson 3 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
swap the Shop repository implementation without touching controllers or services; prepares JNR-026-LAB1.
Draft outline details
Step by step
- Show the existing
ProductRepositoryinterface and the in-memory implementation. - Apply
schema.sqlmanually in local PostgreSQL and add the datasource properties. - Create
JdbcProductRepository implements ProductRepositoryusingJdbcClientand a shared mapper. - Planned mistake: forget the
@Repository/bean switch so two implementations exist; show the startup error and remove the in-memory bean. - Run the existing API tests; they pass unchanged.
- Add one integration test against a real PostgreSQL database.
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.