O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mastering Spring 5

Book Description

Build scalable and flexible Rest APIs and microservices using the latest versions of Spring and Spring Boot

Key Features

  • Build Java-based enterprise applications using Spring 5.1 and Spring Boot 2.1
  • Create high performing, reusable, and scalable enterprise Java applications that are easy to test
  • Gain powerful insights into advanced Spring and Spring Boot concepts to develop applications effectively

Book Description

Spring 5.1 is the latest release of the widely used Spring Framework. This book takes you through the evolution of building enterprise-ready applications with Spring and Spring Boot.

Mastering Spring 5 starts with an overview of some of the important Spring Framework features relating to aspect-oriented programming, task scheduling, and scripting with the help of practical examples. You'll learn about the standard dependency injection specification for Java contexts and CDI and how the Spring Framework supports it. You'll gain an understanding of how application architectures have evolved from monoliths to microservices and be able to build your own microservices using Spring Boot. Complete with real-world examples, this book will help you gain powerful insights into Spring Boot 2.1 and learn how to develop cloud-native microservices with Spring Cloud. You'll even explore how to secure a REST API with Spring Security and get started with your first full stack application using React. Furthermore, you'll get to grips with Kotlin fundamentals and build a Kotlin project in Eclipse.

By the end of this book, you'll be equipped with all the knowledge required to develop microservices and full stack applications with the Spring Framework.

What you will learn

  • Explore Spring Framework 5.1 features such as AOP, transaction management, task scheduling, and scripting
  • Build REST APIs and microservices with Spring and Spring Boot
  • Develop a secure REST API with Spring Security
  • Build your first full stack React application
  • Write efficient unit tests with Spring and Spring Boot
  • Understand the advanced features that Spring Boot offers for developing and monitoring applications
  • Use Spring Cloud to deploy and manage applications on the Cloud

Who this book is for

This book is for experienced Java and enterprise Java developers and programmers who have a basic understanding of the Spring Framework.

Downloading the example code for this ebook: You can download the example code files for this ebook on GitHub at the following link:https://github.com/PacktPublishing/Mastering-Spring-5.1. If you require support please email: customercare@packt.com

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering Spring 5 Second Edition
  3. About Packt
    1. Why subscribe?
  4. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Section 1: Getting Started with Spring and Spring Boot
  7. Spring Landscape - Framework, Modules, and Projects
    1. Exploring Spring and its evolution
      1. Beginning with the first version of the Spring Framework
        1. Loose coupling and testability
        2. Architectural flexibility
        3. Reduction in plumbing code
      2. Learning about the early years of the Spring Framework – Spring Projects
        1. Staying ahead of Java EE
      3. Evolution toward microservices – Spring Boot and Spring Cloud
        1. Building microservices quickly with Spring Boot
        2. Connecting microservices with the cloud using Spring Cloud
      4. Quickly revising what we learned
    2. Learning about Spring Modules
      1. Spring Core Container
      2. Cross-cutting concerns
      3. Web – Spring MVC
      4. The business layer
      5. The data layer
    3. Beginning with Spring Projects
      1. Spring Boot
      2. Spring Cloud
      3. Spring Data
      4. Beginning with Spring Batch
      5. Spring Security
      6. Spring HATEOAS
    4. New features in Spring Framework 5.0 and 5.1
      1. Baseline upgrades
      2. Java 11 Support
      3. Usage of JDK 8 features in the Spring Framework code
      4. Reactive programming support
      5. Functional web framework
      6. Java modularity with Jigsaw
      7. Kotlin support
      8. Dropped features
    5. Learning about new features in Spring Boot 2.0 and 2.1 
    6. Summary
    7. Further reading
  8. Dependency Injection and Unit Testing
    1. Technical requirements
    2. Understanding a dependency
      1. Why do we have dependencies?
    3. What is DI?
      1. Loose and tight coupling
      2. Eliminating tight coupling and making code loosely coupled
        1. Creating an interface for DataServiceImpl
        2. Moving creation of a dependency outside BusinessServiceImpl
        3. Creating an interface for BusinessServiceImpl
        4. Understanding terminology – beans, wiring, and DI
    4. What does the Spring Framework do?
      1. Question 1 – how does Spring IoC container know which beans to create?
      2. Question 2 – how does the Spring IoC container know the dependencies of the bean?
      3. Launching a Spring IoC container
        1. Creating a Java configuration for the application context
        2. Launching a Java configuration
        3. Defining a component scan
          1. Running the application context
        4. What's happening in the background?
    5. Understanding the Spring Framework in depth
      1. Container Managed Beans
      2. Java versus XML configuration
        1. Using XML configuration for the application context
          1. Defining the XML Spring configuration
          2. Launching an application context with the XML configuration
      3. The @Autowired annotation in depth
        1. The @Primary annotation
        2. The @Qualifier annotation
      4. Understanding DI options
        1. The setter injection
        2. The constructor injection
        3. Constructor versus setter injection
      5. Customizing Spring beans – scope
      6. Other important Spring annotations
    6. Exploring CDI
      1. An example of CDI
    7. Unit testing the Spring application context
      1. What is unit testing?
      2. Writing JUnit using the Spring context
      3. Unit testing with mocks
    8. Summary
    9. Further reading
  9. Building Web Applications with Spring MVC
    1. Technical requirements
    2. Understanding the architectures of Java servlet web applications
      1. Model 1 architecture
      2. Model 2 architecture
      3. Model 2 FrontController architecture
    3. Learning Spring MVC with six basic flow examples
      1. Setting up a Spring MVC application
        1. Adding dependency for Spring MVC
        2. Adding DispatcherServlet to web.xml
        3. Creating a Spring context
      2. Flow 1 – simple controller flow without View
        1. Creating a Spring MVC controller
        2. Running the web application
      3. Flow 2 – creating a simple controller flow with a View – JSP
        1. Creating a Spring MVC controller
        2. Creating a View – a JSP
          1. Configuring a View resolver
      4. Flow 3 – controller redirecting to a View with a model
        1. Spring MVC controller
        2. Creating a View
      5. Flow 4 – controller redirecting to a View with ModelAndView
        1. Spring MVC controller
        2. Creating a View
      6. Flow 5 – controller redirecting to a View with a form
        1. Creating a command or form-backing object
        2. The controller method to show the form
        3. Creating the View with a form
        4. Controller get method to handle form submit
      7. Flow 6 – adding validation to the previous flow
        1. Adding the Hibernate Validator dependency
        2. Defining simple validations on the bean
        3. Implementing custom validations
    4. An overview of Spring MVC
      1. Understanding the important features
      2. Working with Spring MVC
    5. Important concepts behind Spring MVC
      1. RequestMapping
        1. Examples of request mapping
          1. Example 1
          2. Example 2
          3. Example 3
        2. RequestMapping methods – supported method arguments
        3. RequestMapping methods – supported return types
      2. Exploring View resolution
        1. Configuring the JSP View resolver
        2. Configuring Freemarker
      3. Exploring handler mappings and interceptors
        1. Defining a HandlerInterceptor
        2. Mapping HandlerInterceptor to handlers
      4. Using model attributes
      5. Using session attributes
        1. Putting an attribute in the session
        2. Reading an attribute from the session
        3. Removing an attribute from the session
      6. Understand the need for InitBinders
      7. Implementing common features using the @ControllerAdvice annotation
    6. A quick look at Spring MVC advanced features
      1. Implementing exception handling
        1. Common exception handling across controllers
          1. Defining the error View
        2. Creating specific exception handling in a Controller
      2. Internationalizing your application
        1. Setting up the message bundle 
        2. Configuring SessionLocaleResolver
        3. Configuring CookieLocaleResolver
      3. Serving static resources
        1. Exposing static content
        2. Caching static content
        3. Enabling gzip compression of static content
      4. Integrating Spring MVC with Bootstrap
        1. Defining Bootstrap WebJar as a Maven dependency
        2. Configuring the Spring MVC resource handler to deliver WebJar static content
        3. Using Bootstrap resources in JSP
    7. Unit testing Spring MVC applications – basic flows
      1. Flow 1 – simple controller flow without View
        1. Setting up the controller to test
        2. Writing the Test method
      2. Flow 2 – simple controller flow with a View
        1. Setting up the controller to test
        2. Writing the Test method
      3. Flow 3 – controller redirecting to a View with Model
        1. Setting up the controller to test
        2. Writing the Test method
      4. Flow 4 – controller redirecting to a View with ModelAndView
      5. Flow 5 – controller redirecting to a View with a form
      6. Flow 6 – adding validation to the previous flow
        1. Controller setup
        2. The Test method
    8. Writing integration tests for Spring MVC controllers
    9. Spring Security
      1. Adding the Spring Security dependency
      2. Configuring a filter to intercept all requests
      3. Logout
    10. Summary
    11. Further reading
  10. Getting Started with Spring Boot
    1. Technical requirements
    2. What is Spring Boot?
      1. Steps involved in building a quick prototype for an application
      2. Primary goals of Spring Boot
      3. Understanding Spring Boot's non-functional features
    3. Building a Hello World application with Spring Boot
      1. Creating pom.xml with spring-boot-starter-parent
        1. Understanding spring-boot-starter-parent
      2. Configuring pom.xml with starter projects
        1. Understanding starter projects
      3. Configuring spring-boot-maven-plugin
      4. Creating your first Spring Boot launch class
        1. Understanding the SpringApplication class
        2. Requirements for the @SpringBootApplication annotation
      5. Running our Hello World application
      6. Understanding the magic of AutoConfiguration
      7. Exploring Spring Boot starter projects
    4. Getting started with SPRING INITIALIZR
      1. Creating your first SPRING INITIALIZR project
        1. Exploring pom.xml
        2. Understanding the FirstSpringInitializrApplication.java class
        3. Looking at the tests – the FirstSpringInitializrApplicationTests class
    5. A quick peek into AutoConfiguration
    6. Externalizing application configuration
      1. Getting started with application.properties
      2. Customizing frameworks through application.properties
        1. Configuring logging
        2. Customizing the embedded server configuration
        3. Configuring Spring MVC
        4. Configuring Spring starter security
        5. Customizing data sources, JDBC, and JPA
        6. Looking at other configuration options
      3. Defining application-specific, custom-defined properties
        1. Providing type-safe configuration through configuration properties 
      4. Creating profiles for different environments
        1. Configuring dynamic beans based on active profiles
      5. Other options for providing application configuration
      6. Exploring the YAML configuration
    7. Understanding embedded servers
      1. Understanding traditional Java application deployment
      2. Understanding embedded servers
      3. Switching to Jetty and Undertow embedded servers
      4. Building a traditional WAR file instead of using a JAR
    8. Using developer tools to improve productivity
      1. Enabling live reload on a browser
    9. Using Spring Boot Actuator for application monitoring
      1. Using the HAL browser to browse actuator endpoints
      2. Looking at application configuration
      3. Getting environment details
      4. Monitoring application health
      5. Getting mapping information
      6. Debugging with the bean configuration
      7. Exploring important metrics
      8. Getting debug information about AutoConfiguration
      9. Debugging
    10. Summary
  11. Digging Deeper into the Spring Framework
    1. Technical requirements
    2. Exploring AOP with Spring and AspectJ
      1. Exploring cross-cutting concerns and AOP
      2. Understanding important AOP terminology
        1. Understanding weaving
      3. AOP frameworks
      4. Getting hands-on with AOP
        1. Setting up a simple business scenario
          1. Identifying the PointCut
          2. Defining the aspect
          3. Understanding @After advice
          4. Understanding @AfterReturning advice
          5. Understanding @Around advice
        2. PointCut best practices
        3. Defining custom AOP annotations
    3. Scheduling tasks with Spring
      1. Scheduling tasks with @Scheduled
      2. Running tasks asynchronously using @Async
        1. Returning values from @Async methods
      3. Understanding task executors
    4. Scripting with the Spring Framework
      1. JSR 223 – scripting for the JavaTM platform
        1. Executing JavaScript code in Java
        2. Executing Groovy code in Java
      2. Executing Groovy code in Spring enterprise applications
        1. Inlining Groovy code into Spring context XML
    5. Summary
  12. Section 2: Building a REST API and Full Stack Applications with Spring
  13. Building REST APIs with Spring Boot
    1. Understanding REST
    2. Designing your first REST API
      1. Deciding on request methods and URIs for REST API operations
      2. Understanding the high-level approach for creating APIs
    3. Creating a Hello World API with Spring Boot
      1. Creating an API that returns a Hello World string
      2. Creating a REST API that returns a welcome JSON response
        1. Executing a request
      3. Creating a welcome message with a name path variable
        1. Executing a request
    4. Creating a todo REST API
      1. Setting up beans and services
      2. Retrieving a todo list
        1. Executing the service
      3. Retrieving details for a specific Todo
        1. Executing the service
      4. Adding a Todo
        1. Introducing Postman – a REST API client
        2. Executing the POST service using Postman
      5. Updating a Todo
        1. Executing the PUT service using Postman
      6. Deleting a Todo
        1. Executing the DELETE service using Postman
    5. Implementing exception handling for REST APIs
      1. Understanding Spring Boot default exception handling
        1. What happens when a resource doesn't exist?
        2. What happens when service code throws a runtime exception?
        3. What happens when the service method throws a custom exception?
      2. Customizing the exception response
        1. Defining the exception response structure
        2. Defining custom exception handling advice for TodoNotFoundException
        3. Defining global default exception handling advice for all other exceptions
        4. Mapping response statuses for different scenarios
    6. Exploring HATEOAS
      1. Sending HATEOAS links in response
        1. Spring Boot starter HATEOAS
    7. Implementing validation for REST APIs
      1. Enabling validation on the controller method
      2. Defining validations on the bean
    8. Documenting REST services using the OpenAPI Specification
      1. Generating a Swagger specification
      2. Exploring the Swagger specification
        1. Using the Swagger UI to navigate the Swagger documentation
        2. Customizing the Swagger documentation using annotations
    9. Implementing internationalization for REST APIs
    10. Implementing caching for REST APIs
      1. Exploring a starter project for caching – spring-boot-starter-cache
      2. Enabling caching on the application
      3. Caching data
      4. JSR-107 caching annotations
        1. Understanding the auto-detection order of caching providers
    11. Deploying Spring Boot applications to the cloud
      1. Deploying applications to Cloud Foundry
    12. Summary
  14. Unit Testing REST API with Spring Boot
    1. Technical requirements
    2. Unit testing REST API with Spring Boot
      1. Adding dependency on Spring Boot Starter Test
      2. Unit tests for the BasicController API
        1. Setting up the basic unit test
        2. Writing a unit test for the Hello World API returning a string
        3. Writing a unit test for the Hello World API returning a JSON
        4. Writing a unit test for the Hello World API with a path parameter
      3. Unit tests for the TodoController API
        1. Setting up unit tests for the TodoController API
        2. Writing a unit test to retrieve all todos – the GET method
        3. Writing a unit test for retrieving a specific todo – the GET method
        4. Writing a unit test for creating a todo – the POST method
        5. Writing a unit test for creating a todo with validation errors
        6. Writing a unit test for updating a todo – the PUT method
        7. Writing a unit test for deleting a todo – the DELETE method
    3. Integration testing REST API with Spring Boot
      1. Writing integration tests for BasicController
        1. Writing an integration test for the Hello World API returning a string
        2. Writing an integration test for the Hello World API returning a JSON
        3. Writing an integration test for the Hello World API with a path parameter
      2. Integration tests for the TodoController API
        1. Todo API integration testing setup
        2. Writing an integration test to retrieve all todos – the GET method
        3. Writing an integration test for creating a todo – the POST method
        4. Writing an integration test for updating a todo – the PUT method
        5. Writing an integration test for deleting a todo – the DELETE method
    4. Unit and integration testing best practices
    5. Summary
    6. Further reading
  15. Securing REST API with Spring Security
    1. Technical requirements
    2. Security REST API with Spring Security
      1. Securing the REST API basics
        1. Authentication
        2. Authorization
      2. Implementing security for REST API
      3. Adding Spring Security to the Todo API
        1. Adding Spring Security Starter
          1. Spring Boot Starter security dependencies
          2. Spring Boot Starter security auto-configuration
          3. Updating an integration test with basic authentication credentials
          4. Updating a unit test to disable security
          5. A quick review of the chapter until now
    3. Understanding Spring Security
      1. Reviewing the log
      2. Understanding Spring Security filters
      3. Understanding authentication in Spring Security
        1. Understanding authentication managers
          1. Understanding provider managers
          2. Understanding authentication providers
          3. Implementing the UserDetailsService
        2. Managing users with a UserDetailsManager
      4. Understanding authentication extension points in Spring Security
        1. Providing a custom implementation of the Use DetailsService
        2. Extending the web security configurer adapter to configure a global authentication manager
        3. Using the web security configurer adapter to configure web security
      5. Understanding authorization in Spring Security
        1. Using access decision manager to support authorization
      6. Understanding authentication extension points in Spring Security
        1. Using the web security configurer adapter to configure HTTP security
      7. Providing secured annotations on service methods
      8. Providing JSR-250 annotations on service methods
      9. Using Spring Security pre and post annotations
      10. Implementing security best practices with Spring Security
    4. Exploring OAuth2 authentication
      1. Understanding OAuth2 high-level flow
        1. Exploring Authorization Grant Flow
        2. Resource Access Flow
      2. Creating the OAuth2 Server
        1. Setting up the authorization server
          1. Configuring the user credentials for REST API
          2. Configuring the authorization server with third-party client credentials
          3. Obtaining an access token
        2. Setting up the resource server
          1. Executing the request using the access token
        3. Updating the integration test
    5. Authentication with JWT
      1. Introducing JWT
        1. JWT payload
        2. JOSE header
        3. JWT signing and token creation
        4. Using JWT for REST API authentication
      2. Using JWT with OAuth2
    6. Summary
    7. Further reading
  16. Full Stack App with React and Spring Boot
    1. Technical requirements
    2. Understanding full stack architecture
      1. Understanding the need for full stack architecture
    3. Introducing React
      1. Components of a frontend application
      2. JSX
      3. Combining JSX and components
        1. Creating a Header component
        2. Creating a Footer component
        3. Creating a Todo component
    4. Building your first React application
      1. Using create-react-app
      2. Importing a React application into Visual Studio Code IDE
        1. Quick introduction to the folder structure
      3. Initializing the React framework 
      4. Creating a Todo component
      5. Adding basic Todo management features
        1. Validations
        2. Loading Todos from the API with the axios framework
      6. Adding todos invoking the RESTful API
      7. Authentication
        1. Basic authentication
        2. JWT token-based authentication
    5. Summary
    6. Further reading
  17. Managing Data with Spring Data
    1. Technical requirements
    2. Challenges with a variety of data stores
    3. Communicating with relational databases
    4. Introducing Spring Data
      1. Understanding Spring Data Commons
        1. Exploring the Repository interface
        2. Exploring the CrudRepository interface
        3. Exploring the PagingAndSortingRepository interface
    5. Connecting to relational databases using Spring Data JPA
      1. Understanding Spring Data JPA with an example
        1. Create a new project with a starter data JPA
        2. Defining entities
        3. Creating the SpringBootApplication class
        4. Populating some data
        5. Creating a simple repository
          1. Creating a unit test
        6. Create a repository extending the CrudRepository interface
          1. Testing using a unit test
        7. Creating a repository extending the PagingAndSortingRepository interface
          1. Exploring using unit tests
        8. Writing custom query methods
        9. Writing custom JPQL queries
          1. Using named parameters
          2. Using named queries
          3. Executing native SQL queries
      2. Getting started with transaction management
        1. Understanding the Spring @Transactional annotation
        2. Understanding Spring Boot auto-configuration for transactions
    6. Interacting with MongoDB using Spring Data
      1. Setting up the dependencies
      2. Creating a Person entity
      3. Creating a Person repository
      4. Testing the repository in a unit test
    7. Using Spring Data REST to create REST APIs
      1. Exploring the GET method
      2. Exploring the POST method
      3. Using the search resource
    8. Summary
  18. Section 3: Cloud, Microservices, and Best Practices with Spring
  19. Getting Started with Microservices
    1. Understanding the goals of application development
      1. Developing applications quickly – speed
      2. Building dependable applications – safety
        1. Reliability – does the application behave as expected?
        2. Availability – is your application available all the time?
        3. Security – is your application secure?
        4. Performance – is your application quick enough?
        5. High resilience – does your application react well to failures?
        6. Scalability – what is needed to support a drastic increase in application load?
    2. Challenges with monolithic applications
      1. Challenges in releasing updates – long release cycles
      2. Difficulties with scaling up
      3. Difficulties with adapting new technologies
      4. Difficulties with adapting new methodologies
      5. Challenges in adapting modern development practices
    3. Getting started with microservices
      1. What is a microservice?
      2. Understanding the big idea of microservice architecture
      3. Understanding microservice characteristics
        1. Small and lightweight microservices
        2. Interoperability with message-based communication
        3. Capability-aligned microservices
        4. Independently deployable microservices
        5. Stateless microservices
        6. Completely automated build and release process
        7. Adherence to event-driven architectures
          1. Approach 1 – The sequential approach
          2. Approach 2 –  The event-driven approach
        8. Independent teams developing and supporting microservices – DevOps
      4. Understanding the advantages of microservice architectures
        1. Faster time to market
        2. Quick adaptation to technology evolution
        3. Ability to easily scale
        4. Compatibility with current development methodologies
      5. Exploring microservice challenges
        1. Increased need for automation
        2. Challenges in defining the boundaries of subsystems
        3. Increased need for visibility and monitoring
        4. Increased need for fault tolerance
        5. Maintaining consistency across microservices
          1. Establishing standardized shared capabilities (enterprise level)
        6. Increased need for operations teams
    4. Understanding cloud-native applications
      1. What is the Twelve-Factor App?
        1. Maintain one code base
        2. Explicit declaration of dependencies
        3. Application configuration stored in an environment
        4. All dependencies are treated as backing services
        5. Clear separation between build, release, and run phases
        6. Applications do not store states – stateless
        7. All the services are exposed with port binding
        8. Possibility to scale horizontally – concurrency
        9. Each application instance is disposable
        10. Achieving environmental parity – all environments are the same
        11. Treating all logs as event streams
        12. No distinction for admin processes
    5. Exploring Spring projects for microservices
      1. Getting an overview of Spring Boot
      2. Getting started with Spring Cloud
        1. Exploring Spring Cloud Netflix
    6. Summary
    7. Further reading
  20. Building Microservices with Spring Boot and Spring Cloud
    1. Technical requirements
    2. Understanding the microservices we will build
      1. Setting up Microservice A
        1. Step 1 – initializing Microservice A using SPRING INITIALIZR
        2. Step 2 – creating the random list service in Microservice A
      2. Building the Service Consumer microservice
        1. Creating the method to consume the random list service (from Microservice A)
        2. Testing the Service Consumer microservice
        3. Standardizing ports that are used for different microservices
    3. Using recommended versions for Spring Boot and Spring Cloud
    4. Exploring centralized microservice configuration
      1. Problem statement
      2. Solution
      3. Options
      4. Spring Cloud Config
        1. Implementing Spring Cloud Config Server
          1. Setting up Spring Cloud Config Server
          2. Creating a service in Microservice A to return a message from the application configuration
          3. Connecting Spring Cloud Config Server to a local Git repository
          4. Creating a development environment-specific configuration for Microservice A
          5. Enhancing Microservice A to make it a Spring Cloud Config Client
    5. Getting an overview of event-driven approaches
      1. Understanding Spring JMS using the JMS API
      2. AMQP 
    6. Getting started with Spring Cloud Bus
      1. The need for Spring Cloud Bus
      2. Propagating configuration changes using Spring Cloud Bus
      3. Implementing Spring Cloud Bus 
    7. Declarative REST client – Feign
    8. Implementing load balancing for microservices
      1. Ribbon for client-side load balancing
        1. Implementing Ribbon in the Service Consumer microservice
    9. Understanding the need for a naming server
      1. Limitations of hardcoding microservice URLs
    10. The working of a naming server
      1. Naming server options supported by Spring Cloud
      2. Implementing the Eureka naming service
        1. Setting up Eureka Server
        2. Registering microservices with Eureka
        3. Connecting the Service Consumer microservice with Eureka
    11. Understanding API gateways
      1. Implementing API gateway with Zuul
        1. Setting up a new Zuul API gateway server
          1. Configuring Zuul custom filters for logging every request
          2. Invoking microservices through Zuul
        2. Configuring Service Consumer to use the Zuul API gateway
    12. Understanding distributed tracing
      1. Implementing Spring Cloud Sleuth and Zipkin
        1. Integrating microservice components with Spring Cloud Sleuth
        2. Setting up a Zipkin distributed tracing server
        3. Integrating microservice components with Zipkin
    13. Implementing fault tolerance with Hystrix
      1. Integrating Hystrix into the Service Consumer microservice
    14. Summary
    15. Further reading
  21. Reactive Programming
    1. Technical requirements
    2. The reactive manifesto
      1. Characteristics of reactive systems
    3. Reactive use case – a stock price page
      1. A quick look at the traditional approach 
      2. How is the reactive approach different?
      3. Comparing traditional and reactive approaches
    4. Implementing reactive programming in Java
      1. Understanding Reactive Streams
      2. Exploring the Reactor framework
        1. Using Mono to emit one element
        2. Using Flux to emit multiple elements
      3. Creating Reactive web applications with Spring Web Reactive
        1. Creating a project using Spring Initializr
        2. Creating a reactive controller – StockPriceEventController
        3. Creating an HTML view – stock-price.html
        4. Launching SpringReactiveExampleApplication
      4. Integrating with reactive databases
        1. Integrating the Spring Boot Reactive MongoDB starter
        2. Creating a model object – a stock document
        3. Creating ReactiveCrudRepository
        4. Initializing stock data using CommandLineRunner
        5. Creating reactive methods in the REST controller
        6. Updating the view to subscribe to the event stream
        7. Launching SpringReactiveExampleApplication
    5. Summary
  22. Spring Best Practices
    1. Adhering to Maven's standard directory layout
    2. Building applications using a layered architecture
    3. Having separate context files for different layers
    4. Separating api and impl for important layers
    5. Understanding exception handling best practices
      1. Spring's approach to exception handling
      2. The recommended approach
    6. Keeping your Spring configuration light
    7. Using the basePackageClasses attribute in ComponentScan
    8. Not using version numbers in schema references
    9. Preferring constructor injection for mandatory dependencies
    10. Managing dependency versions for Spring projects
    11. Exploring unit testing best practices
      1. Writing tests for the business layer
      2. Writing tests for the web layer
      3. Writing tests for the data layer
      4. Other application development best practices
    12. Exploring integration testing best practices
      1. Using Spring Session to manage session
      2. Implementing Spring Session with Redis
        1. Adding dependencies for Spring Session
        2. Configuring the filter to replace a HttpSession with Spring Session
        3. Enabling filtering for Tomcat by extending AbstractHttpSessionApplicationInitializer
    13. Exploring caching best practices
      1. Adding the spring-boot-starter-cache dependency
      2. Adding caching annotations
    14. Understanding best practices for logging
      1. Using the Logback framework
      2. log4j2
      3. Providing framework independent configuration
    15. Summary
  23. Working with Kotlin in Spring
    1. Technical requirements
    2. Getting started with Kotlin
    3. Comparing Kotlin and Java
      1. Creating variables and understanding type inference
      2. Understanding the immutability of variables
      3. A quick look at the type system
      4. Understanding null safety
      5. Defining functions in Kotlin
      6. Playing with arrays
      7. Exploring Kotlin collections
      8. No checked exceptions
      9. Using a data class for beans
    4. Creating a Kotlin project in Eclipse
      1. Kotlin plugin
      2. Creating a Kotlin project
      3. Creating a Kotlin class
      4. Running a Kotlin class
    5. Creating a Spring Boot project using Kotlin
      1. Adding dependencies and plugins to pom.xml
      2. Spring Boot application class
      3. Spring Boot application test class
    6. Implementing the REST service using Kotlin
      1. A simple method returning a string
        1. Writing a unit test
        2. Writing an integration test
      2. Simple REST method returning an object
        1. Executing a request
        2. Writing a unit test
        3. Writing an integration test
      3. GET method with path variables
        1. Executing a request
        2. Writing a unit test
        3. Writing an integration test
    7. Summary
  24. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think