O'Reilly logo
live online training icon Live Online training

Learning Spring Boot 2

Increase the productivity and reliability of a Spring Framework-based project

Bogdan Solga

Spring Boot is a set of tools and conventions that helps developers to start an enterprise Spring Framework-based application in a fast and reliable mode. It uses an opinionated approach on the project structure and configuration, making it easier to extend, scale and deploy in multiple development environments. The Spring Boot tools and conventions are designed to be used on top of the Spring Framework, further extending its benefits for the programmers and allowing them to focus on the most important aspect from an application - the business logic. As Spring Boot-based applications are designed to be lightweight and self-contained, Spring Boot is one of the building blocks for the microservices architectural paradigm, for cloud native applications and for containerized applications. Spring Boot 2 further enhances the support for microservices and cloud native deployments, by providing first-order support for developing reactive (non-blocking) applications.

This course presents the features and benefits of the Spring Boot project as well as it’s non-functional features, including remote management, monitoring and metrics, through cloud and on-premise deployments.

What you'll learn-and how you can apply it

  • What is Spring Boot and how it can help you start and develop a Spring Framework-based application in a fast and reliable way
  • How Spring Boot is further extending the features and benefits brought by the Spring Framework
  • How to use the Spring Boot ‘starter’ modules to easily add functional and non-functional application parts, such as: web and database access, messaging, security, and monitoring
  • How to use Spring Boot-based applications in several development environments
  • How to properly test a Spring Boot application, through unit and integration tests
  • How to package and deploy Spring Boot applications
  • How to monitor a running Spring Boot application

This training course is for you because...

You are a developer who is already familiar with the Spring Framework and who wishes to further improve your proficiency through the tools and conventions brought by Spring Boot, and write more maintainable and scalable enterprise applications.

Prerequisites

Intermediate-level knowledge of: Spring Framework, Functional programming in Java ( → Java 8+), and Maven.

Materials, downloads, or Supplemental Content needed in advance

Install and/or setup the following prerequisites prior to joining the session: - JDK 8 or 11 - IntelliJ IDEA (either the Community or the Ultimate version) - PostgreSQL 11 - Review the Git repository: https://github.com/bogdansolga/packt-spring-boot-training

Resources The Packt ‘Spring Framework for beginners’ video material is advised for the training participants, before attending the current training.

About your instructor

  • Bogdan has 10 years of software development and technical leadership experience and 2 years of experience in the delivery of technical training, mentoring and coaching on enterprise Java and microservices ecosystems. Bogdan’s current skill set comprises mentoring and training Agile teams on software architecture, development, and testing, as well as and improving projects based on Spring, Spring Boot and Spring Cloud / microservices. When he is not lobbying for clean coding and software design patterns, Bogdan is either running marathons, reading behavioural economics books or traveling around the world.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

DAY 1

Section 1: Spring Boot intro, auto-configuration support (50 Minutes)

  • Spring Boot intro

Lab 1.1: Generating a new Spring project using the Spring Initializr site, analyzing its structure and new elements (10 min activity)

  • New features in Spring Boot 2
  • Spring Boot apps best practices
  • Auto-configuration overview

Lab 1.2: Using autoconfiguration to add new features in a project (10 min activity)

Break – 10 Minutes

Section 2: Configuration files, Profiles and Spring web support (50 Minutes)

  • Spring Boot configuration files

Lab 2.1: Adding a configuration file to the project (5-10 min activity) - Profiles

Lab 2.2: Defining a profile and adding its configuration file in the project (7-10 min activity) - Spring MVC overview, short REST demo

Lab 2.3: Adding REST support to the project, exposing a few REST endpoints (7-10 min activity)

Break – 10 Minutes

Section 3: Spring web support continued, exception and error handling (50 Minutes)

  • Spring WebFlux overview

Lab 3.1: Adding WebFlux support to the project, exposing a few WebFlux endpoints (10 min activity) - Serving static content

Lab 3.2: Adding a short example of a static content to the project (5 min activity) - Other web access methods - Exception and error handling

Lab 3.3: Adding exception and error handling support to the project (7-10 min activity)

Break – 10 Minutes

Section 4: Database configuration (50 Minutes)

  • Using an embedded database

Lab 4.1: Adding the embedded database support to the project, persisting an entity in it (5-10 min activity) - Using a real database (PostgreSQL)

Lab 4.2: Adding the support for the PostgreSQL database to the project, persisting an entity in it (7-10 min activity) - Custom data-source & connection pooling - Spring Data JPA overview

Lab 4.3: Adding a Spring Data JPA repository, persisting an entity with it (7 min activity) - Transactional operations

Break – 10 Minutes

DAY 2

Section 5: Unit and integration testing, Spring Security (50 Minutes)

  • Automated testing overview
  • Unit tests using Spring Boot, JUnit 5 and Mockito

Lab 5.1: Adding unit tests support to the project, writing a unit test for a service (10-15 min activity) - Integration tests - standalone and using RestAssured

Lab 5.2: Adding integration tests support to the project, writing a unit test for a service (10-15 min activity) - Overview of the rest of types of Spring Boot tests - Spring security integration, form authentication demo, session persistence overview

Lab 5.3: Securing a REST endpoint and testing the security on it (7 min activity)

Break – 10 Minutes

Section 6: Conditional annotations, ConfigurationProperties and Spring Boot events (50 Minutes)

  • Conditional annotations

Lab 6.1: Adding a conditional annotation to the project and testing its correct functioning (5-10 min activity) - Using ConfigurationProperties classes

Lab 6.2: Adding a ConfigurationProperties class to the project and testing its correct functioning (7-12 min activity) - Spring and Spring Boot events

Lab 6.3: Adding a Spring Boot event on a class, testing its correct functioning (5-10 min activity)

Break – 10 Minutes

Section 7: Spring Boot messaging support overview, Spring Boot Actuator and developer tools (50 Minutes)

  • Spring Boot messaging support overview
  • Spring Boot Actuator

Lab 7.1: Adding Actuator support to the project and testing its correct functioning (7-10 min activity) - Spring Boot developer tools

Lab 7.2: Adding support for the developer tools, testing their correct functioning (7-10 min activity)

Break – 10 Minutes

Section 8: Packaging and running the app, Spring Boot Admin (50 Minutes)

  • Spring Boot Maven plugin and its configuration options

Lab 8.1: Adding the Spring Boot plugin to the project, configuring it (5-7 min activity) - Packaging and running the app

Lab 8.2: Packaging and running the application (7-10 min activity) - Using an application as a service - Spring Boot Admin - Final Q&A session

Final Q&A – 10 Minutes

Wrap up: Session Summary, Discussion - 10 minutes