Spring Boot in Practice

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Go beyond the basics with Spring Boot! This practical guide presents dozens of relevant scenarios in a convenient problem-solution-discussion format. In Spring Boot in Practice you will learn: • Spring Boot’s features from an expert’s perspective • Configuring, logging, and monitoring Spring Boot applications • Effective methods for database communication • Utilizing Spring Security and securing your Spring application in production • Designing and developing microservices and RESTful APIs with Spring Boot • Microservice versioning, documentation, and security • Reactive application development and reactive data access with WebSocket and RSocket • Deploying Spring Boot applications on Kubernetes and major cloud platforms • Implementing containerization in a Spring Boot application • Using Spring Boot with Kotlin and GraalVM Spring Boot in Practice is full of practical recipes for common development problems in Spring Boot. Author Somnath Musib has spent years building applications with Spring, and he shares that extensive experience in this focused guide. You’ll master techniques for using Spring Data, Spring Security, and other Spring-centric solutions. Learn how to work with Spring Boot and Kotlin, handling connections for multiple platforms, and how Spring Boot can simplify building microservices and APIs. Each recipe is built around a real-world problem, complete with a full solution and thoughtful discussion. About the technology With Spring Boot, it’s a snap to create standalone Spring applications that require minimal manual setup. Spring Boot directly embeds a server like Tomcat or Jetty into your project and preconfigures core Spring settings, third-party libraries, security, and other key elements. It’s a big framework, with lots of powerful features. This book provides a rich collection of techniques to help you get the most out of Spring Boot. About the book Spring Boot in Practice is a cookbook-style guide to Spring application development. Following a convenient Problem-Solution-Discussion format, it takes you technique-by-technique through Spring Boot fundamentals. You’ll dive deep into auto-configuration, security, microservices, and more. Along the way, you’ll also discover numerous advanced and hidden features. All the book’s source code is open source, so you can integrate the detailed samples into your own projects. What's inside • Instantly useful techniques with reusable source code • Configuring, logging, and monitoring Spring Boot applications • Effective methods for database communication • Securing Spring applications in production • Microservices and RESTful APIs About the reader For Spring Boot beginners with some Spring experience. About the author Somnath Musib has over a decade of development experience, and has been actively working with Spring Boot since 2015.

Author(s): Somnath Musib
Edition: 1
Publisher: Manning Publications
Year: 2022

Language: English
Commentary: Vector PDF
Pages: 584
City: Shelter Island, NY
Tags: Java; Web Applications; GraphQL; Reactive Programming; Application Development; Spring Framework; Kotlin; RESTful API; Gradle; Database Access; Spring Boot

Spring Boot in Practice
brief contents
contents
foreword
We might be on to something
preface
acknowledgments
about this book
Who should read this book?
How this book is organized: A roadmap
About the code
liveBook discussion forum
about the author
about the cover illustration
Part 1
1 Booting Spring Boot
1.1 Introducing Spring Boot
1.1.1 Why Spring Boot?
1.1.2 What is Spring Boot?
1.1.3 Spring Boot core features
1.1.4 Spring Boot components
1.2 Code examples
1.2.1 Maven vs. Gradle
1.2.2 Java vs. Kotlin
1.2.3 Database support
1.2.4 Lombok
1.3 Getting started with Spring Boot
1.3.1 Your first Spring Boot project
1.3.2 Spring Boot project structure
1.3.3 Creating an executable JAR file
1.3.4 Exploring the JAR file
1.3.5 Shutting down a Spring Boot application
1.4 Spring Boot additional concepts
1.4.1 Spring Boot startup events
1.4.2 Listening events in a Spring Boot application
1.4.3 Custom Spring Boot starters
1.4.4 Custom autoconfiguration
1.4.5 Failure analyzers
1.4.6 Spring Boot actuator
1.4.7 Spring Boot developer tool
Summary
Part 2
2 Common Spring Boot tasks
2.1 Managing configurations
2.1.1 Using the SpringApplication class
2.1.2 Using @PropertySource
2.1.3 Config data file
2.1.4 OS environment variable
2.2 Creating custom properties with @ConfigurationProperties
2.2.1 Technique: Defining custom properties with @ConfigurationProperties in a Spring Boot application
2.3 Executing code on Spring Boot application startup
2.3.1 Technique: Using CommandLineRunner to execute code at Spring Boot application startup
2.4 Customizing logging in a Spring Boot application
2.4.1 Technique: Understanding and customizing default Spring Boot logging in a Spring Boot application
2.4.2 Technique: Using Log4j2 to configure logging in a Spring Boot application
2.5 Validate user data using Bean Validation
2.5.1 Technique: Using built-in Bean Validation annotations to validate business entity in a Spring Boot application
2.5.2 Technique: Defining and using custom Bean Validation annotation to validate a POJO in a Spring Boot application
Summary
3 Database access with Spring Data
3.1 Introducing Spring Data
3.1.1 Why Spring Data?
3.1.2 Spring Data modules
3.2 Configuring a database in a Spring Boot application
3.2.1 Technique: Configuring a relational database in a Spring Boot application
3.2.2 Technique: Configuring MongoDB database in a Spring Boot application
3.2.3 Technique: Initializing a relational database schema with a Spring Boot application
3.3 Understanding the CrudRepository interface
3.3.1 Technique: Managing domain objects in a relational database with Spring Data JPA
3.3.2 Technique: Creating a custom Spring Data repository with Spring Data JPA to manage domain objects in a relational database
3.4 Retrieve data from a database using Spring Data
3.4.1 Defining query methods
3.4.2 Technique: Defining custom query methods to retrieve domain objects from a relational database with Spring Data JPA
3.4.3 Implementing pagination with PagingAndSortingRepository
3.4.4 Technique: Using PagingAndSortingRepository interface to paginate and sort the data
3.4.5 Specifying query using @NamedQuery
3.4.6 Technique: Using a named query to manage domain objects in a relational database with Spring Data JPA
3.5 Specifying query using @Query
3.5.1 Technique: Using @Query annotation to define queries and retrieve domain objects in a relational database with Spring Data JPA
3.6 Using Criteria API with Spring Data JPA
3.6.1 Technique: Using Criteria API to manage domain objects in a relational database with Spring Data JPA
3.7 Using QueryDSL with Spring Data JPA
3.7.1 Technique: Using QueryDSL to manage domain objects in a relational database with Spring Data JPA
3.8 Managing domain object relationships
3.8.1 Technique: Managing domain objects with many-to-many relationships in a relational database with Spring Data JPA
Summary
4 Spring Boot: Autoconfiguration and Actuator
4.1 Understanding Spring Boot autoconfiguration
4.1.1 Understanding @Conditional annotation
4.1.2 Deep dive into autoconfiguration
4.2 Using Spring Boot DevTools
4.2.1 Property defaults
4.2.2 Automatic restart
4.2.3 Live reload
4.3 Creating a custom failure analyzer
4.3.1 Technique: Creating a custom Spring Boot FailureAnalyzer
4.4 Spring Boot Actuator
4.4.1 Technique: Configuring Spring Boot Actuator in a Spring Boot application
4.4.2 Understanding Spring Boot Actuator endpoints
4.4.3 Managing Spring Boot Actuator endpoints
4.4.4 Health endpoint deep dive
4.4.5 Creating a custom Spring Boot HealthIndicator
4.4.6 Technique: Defining a custom Spring Boot actuator HealthIndicator
4.5 Info endpoint deep dive
4.5.1 Technique: Configuring info Spring Boot Actuator endpoint
4.5.2 Technique: Configuring a custom info contributor to provide custom application info in the Spring Boot Actuator endpoint
4.6 Creating a custom Spring Boot Actuator endpoint
4.6.1 Technique: Creating a custom Spring Boot actuator endpoint
4.6.2 Spring Boot actuator metrics
4.6.3 Creating custom metrics
4.6.4 Gauge
4.6.5 Metrics dashboard with Prometheus and Grafana
Summary
5 Securing Spring Boot applications
5.1 Introducing Spring Security
5.2 Hello Spring Security with Spring Boot
5.2.1 Technique: Enabling application security with Spring Security in a Spring Boot application
5.2.2 Filter, FilterChain, and Spring Security
5.2.3 Spring Security architecture
5.2.4 Authenticating a user
5.2.5 Spring Security autoconfiguration
5.3 Using Spring Security
5.3.1 Technique: Customizing the default Spring Security login page of a Spring Boot application
5.3.2 Technique: Configuring in-memory authentication with custom users in Spring Security in a Spring Boot application
5.3.3 Technique: Configuring JDBC authentication with Spring Security in a Spring Boot application
5.3.4 Technique: Implementing JDBC authentication with custom UserDetailsService in a Spring Boot application
5.3.5 Technique: Implementing LDAP authentication in a Spring Boot application
5.3.6 Technique: Implementing HTTP basic authentication in a Spring Boot application
Summary
6 Implementing additional security with Spring Security
6.1 Enabling HTTPS in a Spring Boot application
6.1.1 Technique: Enabling HTTPS in a Spring Boot application
6.2 Securing secrets in Spring Cloud Vault
6.2.1 Technique: Managing application secrets with HashiCorp Vault in a Spring Boot application
6.3 Implementing user registration
6.3.1 Technique: Implementing user registration with Spring Security in a Spring Boot application
6.4 Implementing email verification at user registration
6.4.1 Technique: Validating user email addresses in a Spring Boot application
6.5 Controlling multiple incorrect login attempts
6.5.1 Technique: Controlling multiple incorrect login attempts in a Spring Boot application
6.6 Implementing a Remember Me feature
6.6.1 Technique: Enabling a Remember Me feature in a Spring Boot application with Spring Security
6.7 Implementing reCAPTCHA
6.7.1 Technique: Enabling Google reCAPTCHA in a Spring Boot application with Spring Security
6.8 Enabling two-factor authentication with Google Authenticator
6.8.1 Technique: Enabling two-factor authentication in a Spring Boot application
6.9 Authentication with OAuth2
6.9.1 Technique: Enabling sign in with Google in a Spring Boot application
6.10 Securing Actuator endpoints
6.10.1 Technique: Securing Spring Boot Actuator endpoints
Summary
7 Developing RESTful Web services with Spring Boot
7.1 Developing a RESTful API with Spring Boot
7.1.1 Technique: Developing a RESTful API using Spring Boot
7.2 Managing exceptions in a Spring Boot RESTful API
7.2.1 Technique: Handling exceptions in a RESTful API
7.3 Testing a RESTful API
7.3.1 Technique: Testing a RESTful API in a Spring Boot application
7.4 Documenting a RESTful API
7.4.1 Technique: Documenting a RESTful API with OpenAPI
7.5 Implementing RESTful API versioning
7.5.1 Technique: Implementing versioning in a RESTful API
7.6 Securing a RESTful API
7.6.1 Technique: Using JWT to authorize RESTful API requests
Summary
Part 3
8 Reactive Spring Boot application development
8.1 Introduction to reactive programming
8.1.1 Backpressure
8.1.2 Benefits of reactive programming
8.2 Understanding Project Reactor
8.3 Introducing Spring WebFlux
8.3.1 Technique: Developing a reactive RESTful API with annotated controllers
8.3.2 Technique: Developing a reactive RESTful API with functional endpoints
8.4 Testing reactive applications
8.4.1 Technique: Using WebClient to build an API client
8.5 Introduction to RSocket
8.5.1 Technique: Developing applications using RSocket and Spring Boot
8.6 Introduction to WebSocket
8.6.1 Technique: Developing an application using WebSocket and Spring Boot
Summary
Part 4
9 Deploying Spring Boot applications
9.1 Running Spring Boot applications as executable JAR files
9.1.1 Technique: Packaging and executing a Spring Boot application as an executable JAR file
9.2 Deploying Spring Boot applications as WAR in the WildFly application server
9.2.1 Technique: Packaging and deploying a Spring Boot application as WAR in the WildFly application server
9.3 Deploying Spring Boot applications in Cloud Foundry
9.3.1 Technique: Deploying a Spring Boot application to Cloud Foundry
9.4 Deploying Spring Boot applications in Heroku
9.4.1 Technique: Deploying a Spring Boot application in Heroku
9.5 Running Spring Boot applications as Docker containers
9.5.1 Technique: Creating a container image and running a Spring Boot application as a container
9.6 Deploying Spring Boot applications in a Kubernetes cluster
9.6.1 Technique: Deploying a Spring Boot application in a Kubernetes cluster
9.7 Deploying Spring Boot applications in Red Hat OpenShift
9.7.1 Technique: Deploying a Spring Boot application in the Red Hat OpenShift platform
Summary
Part 5
10 Spring Boot with Kotlin, Native Image, and GraphQL
10.1 Spring Boot with Kotlin
10.1.1 Technique: Developing a Spring Boot application with Kotlin
10.1.2 Technique: Securing a Spring Boot Kotlin application with Spring Security
10.2 Introducing Spring Native
10.2.1 Introduction to GraalVM
10.2.2 GraalVM native image
10.2.3 Spring Boot native image
10.2.4 Technique: Generating Spring Boot native image using buildpacks
10.2.5 Technique: Generating Spring Boot native image using a Maven plugin
10.2.6 Understanding Spring AOT Maven Plugin
10.3 Spring Boot with GraphQL
10.3.1 Issues with REST
10.3.2 Introduction to GraphQL
10.3.3 Using GraphQL with Spring Boot
10.3.4 Technique: Developing a GraphQL API with a Spring Boot application
10.3.5 Technique: Developing a GraphQL API over WebSocket with a Spring Boot application
Summary
appendix A—Generating and building Spring Boot projects
A.1 Generating Spring Boot applications with Spring Initializr
A.1.1 Introducing Spring Initializr
A.1.2 Technique: Generating a Spring Boot application with the Spring Initializr Web user interface
A.1.3 Technique: Generating a Spring Boot application with Spring Initializr in IntelliJ IDEA IDE
A.1.4 Technique: Generating a Spring Boot Application with Spring Initializr using the Spring Tool Suite
A.1.5 Technique: Generating a Spring application with Spring Initializr in Visual Studio Code
A.1.6 Technique: Generating a Spring Boot application with Spring Initializr using Command Line Interface
A.2 Bootstrapping and executing a Spring Boot application with Spring Boot CLI
A.2.1 Installing the Spring Boot CLI
A.2.2 Technique: Developing a simple Spring Boot application with Spring Boot CLI
A.2.3 Technique: Building a Web application using Spring Boot CLI
appendix B—Spring MVC and Thymeleaf Template Engine
B.1 Revisiting Spring MVC
B.1.1 Front controller design pattern
B.1.2 Understanding request processing
B.2 Understanding Thymeleaf
B.2.1 Displaying attributes
B.2.2 Conditional evaluation
B.2.3 Managing forms
B.3 Enabling a template engine in Spring Boot
B.3.1 Technique: Building a Spring Boot Web application with Thymeleaf
index
Numerics
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y