Featured resource
2026 Tech Forecast
2026 Tech Forecast

1,500+ tech insiders, business leaders, and Pluralsight Authors share their predictions on what’s shifting fastest and how to stay ahead.

Download the forecast
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Core Tech
Labs

Build a Book Catalog API with Spring Boot 4

This hands-on lab is designed to help you complete a book catalog application with Spring Boot 4. A series of guided steps will give you a walkthrough on how to implement some of the core layers that compose a Spring Boot application such as the services in a business layer along with the controller and views of the presentation layer. By the end of the lab, you will have demonstrated your ability to build a fully functioning book catalog capable of adding, editing, and removing books within its inventory.

Lab platform
Lab Info
Level
Beginner
Last updated
Apr 24, 2026
Duration
45m

Contact sales

By clicking submit, you agree to our Privacy Policy and Terms of Use, and consent to receive marketing emails from Pluralsight.
Table of Contents
  1. Challenge

    Introduction

    The purpose of this lab is to guide you through the basics of building an application in Spring Boot 4. This lab will cover the views and controller of the presentation layer, as well as, the service used in the business layer. Since you will be working with a local JSON file for data, the persistence and database layers will be outside the scope of this lab.

    You can run the application after completing the lab by clicking the Run button in the Terminal or by running the command ./gradlew bootRun. Once your application is running, visit your application using this URL: {{localhost:8081}}

    On the Please sign in screen, type admin for the Username and pspassword123 for the Password.

  2. Challenge

    Implementing the Service

    The first component of this application you will need to complete is the BookCatalogService.java. This service contains all of the logic and functions your application will need to perform such as adding, editing, and deleting books.

    The boilerplate code to the service already instantiates the catalog as a list of book data from a json file and sorts it by id for you. Next, you will need to implement the binarySearch() function to search for the index of a book in the book catalogue using the binary search algorithm. Next, you will need to implement the addBook() method, which should generate a new Book based on the given parameters before adding it to the catalog of books. Now, you will to implement the updateBook() method, which will update the specified book in the book catalog with its updated values. Lastly, you will need to implement the removeBook() method, which will use the binarySearch() function you implemented earlier to remove a book from the catalog.

  3. Challenge

    Implementing the Controller

    Now you need to complete the controller for the application, which is located in BookController.java. The controller is responsible for handling HTTP requests from the apps HTML views by using the methods implemented in BookCatalogService. It then passes back data to the views to be displayed for the user.

    The first endpoint you will need to implement is the homePage(). Next, you will need to implement the editBookPage() endpoint for when the user wishes to edit a book currently in the catalog. The updateBook() endpoint is then called after the user has inputted any edits to the book they wish to modify and submits those changes. The addBookPage() is called when the user wishes to add a new book to the catalog. Like the updateBook() endpoint, the addNewBook() endpoint is called after the user has inputted the data for a new book to be added and submits them. Lastly, the deleteBook() endpoint is called when a user wishes to delete a book from the catalog.

  4. Challenge

    Implementing the View

    Lastly, you will need to add some finishing touches to the views layer. In this application, the Thymeleaf template engine from Spring is used to render HTML files such as home.html, add-book.html, and edit-book.html. The controller endpoints you implemented in the previous step dictates which of these HTML files the user is currently viewing at any given time.

    While the HTML files are mostly complete, you will need to add a few Thymeleaf specific attributes to certain elements that will dynamically render data from the catalog. Let's start with home.html. Next, you will need to add the appropriate attribute bindings to add-book.html. Once more, you will also need to add the appropriate attribute bindings to edit-book.html. With all of these tasks completed, the application is now complete and should be fully functional! Refer back to the introduction on running and viewing the application.

About the author

George is a Pluralsight Author working on content for Hands-On Experiences. He is experienced in the Python, JavaScript, Java, and most recently Rust domains.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight