0%

Book Description

Develop diverse real-life projects including most aspects of Spring Boot

Key Features

  • Run production-grade based applications using the Spring WebFlux framework
  • Learn to develop high performance, asynchronous applications with Spring Boot
  • Create robust microservice-based applications with Kotlin using Spring Boot

Book Description

Spring is one of the best tools available on the market for developing web, enterprise, and cloud-ready software. The goal of Spring Boot is to provide a set of tools for quickly building Spring applications that are easy to configure, and that make it easy to create and run production-grade Spring-based applications. Spring Boot 2.0 Projects will get you acquainted with important features of the latest version of this application-building tool and will cover basic, as well as advanced topics.

The book starts off by teaching you how to create a web application using Spring Boot, followed by creating a Spring Boot-based simple blog management system that uses Elasticsearch as the data store. As you make your way through the chapters, you'll build a RESTful web services application using Kotlin and the Spring WebFlux framework. Spring WebFlux is a new framework that helps in creating a reactive application in a functional way. Toward the end of the book, you will build a taxi-hailing API with reactive microservices using Spring Boot and a Twitter clone with a Spring Boot backend. Finally, you'll learn how to build an asynchronous email formatter.

What you will learn

  • Learn the fundamental features of Spring Boot 2.0
  • Customize Spring Boot 2.0 applications
  • Build a basic web application
  • Use Redis to build a taxi-hailing API
  • Create a simple blog management system and a Twitter clone
  • Develop a reactive RESTful web service with Kotlin using Spring Boot

Who this book is for

This book is for competent Spring developers who wish to understand how to develop complex yet scalable applications with Spring Boot. You must have a good knowledge of Java programming and be familiar with the basics of Spring.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Spring Boot 2.0 Projects
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  6. 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. Conventions used
    4. Get in touch
      1. Reviews
  7. Introduction
    1. Technical requirements
    2. Generating Spring Boot Projects
      1. Opening the generated project with IntelliJ
      2. Opening the generated project with STS
    3. Getting started with Spring Boot
      1. Learning about Spring Boot
        1. Anatomy of a Spring Boot application
        2. Supporting the Spring Framework ecosystem in Spring Boot
    4. Changes since Spring Boot 1.x
      1. Registering a Spring Bean using ApplicationContextInitializer
      2. Configuration property binding
        1. New property binding API
        2. Property origin
        3. Tightened rules for governing relaxed property binding
        4. Environment variables with indices
        5. Direct binding of property type java.time.Duration in the ISO-8601 form
      3. Custom endpoints for Spring Boot Actuator using annotations
        1. Exposing a custom Spring Boot Actuator endpoint
        2. Extending a custom endpoint with a specialized implementation for the web
        3. Connecting to a custom endpoint using monitoring and management tools
      4. Custom metrics using Micrometer
      5. Custom health indicator
      6. Using the HTTP/2 protocol
      7. Securing applications with Spring Security
    5. The next milestone
    6. Migration
      1. Using the correct JDK and JVM
        1. Running on Java 9
          1. Tackling JAXBException
          2. Using the correct AspectJ version
          3. Being aware of limitations on Apache Cassandra drivers
          4. Being aware of issues with the Maven Surefire Plugin
      2. Using the upgraded Spring Framework 5.0
        1. Modified CORS support behavior
        2. Removed packages, classes, and methods
        3. Dropped support for frameworks
      3. Using the updated configuration properties
      4. Using the changed servlet-specific server properties
      5. Using the modified template engine extension handling
      6. Using the changed actuator configuration properties
      7. Using the changed actuator base path
      8. Using the renamed actuator endpoints
      9. Using the changed Embedded Container Configuration 
      10. Using the changed default behavior for path mapping
      11. Using the changed default dispatcher types for the servlet filter 
      12. Using the modified transitive dependency to spring-boot-web-starter
      13. Using the changed default proxying strategy 
      14. Using the modified configuration location strategy
      15. Using the changed Jackson/JSON support
      16. Using the changed Spring Boot Actuator security
      17. Using the changed HikariCP default connection pool for JPA
      18. Using the changed default database initialization strategy
      19. Using the changed database schema creation strategy
      20. Using the changed testing support
      21. Using the revised Spring Security
        1. Using the changed default security auto-configuration strategy
        2. Spring Security OAuth2 is migrated to Spring Security core 
        3. Using the AuthenticationManager bean 
      22. Understanding removed features
    7. Summary
    8. Questions
    9. Further reading
  8. Building a Basic Web Application
    1. Technical requirements
    2. Getting started
      1. Web application architecture
        1. Workflow of Spring Web MVC 
      2. Requirements for our web application
        1. The use case diagram 
    3. Using Spring Data JPA for persistence
      1. Understanding the Java Persistence API (JPA)
      2. Understanding Spring Data JPA
      3. Class diagram for the domain model
      4. Implementation of the domain model using JPA annotations
        1. Setting up dependencies and configuration
        2. Implementing the domain model
      5. Implementation of Spring Data JPA repositories
      6. Testing Spring Data JPA repositories
        1. Using Spring Boot Devtools for database visualization
      7. Using Services to encapsulate business logic
      8. Testing Services
    4. Using Spring Thymeleaf for the view
      1. Understanding template engines
      2. Spring Thymeleaf 
      3. UI design for the Retro Board
      4. UI implementation for the Retro Board using Spring Thymeleaf
    5. Using Spring Web MVC with servlet 3.x for the controller
      1. Implementation of Controllers annotations
      2. Testing controllers
    6. Using Spring Security for authentication and authorization
    7. Demonstrating the Retro Board
    8. Summary
    9. Questions
    10. Further reading
  9. Building a Simple Blog Management System
    1. Technical requirements
    2. Getting started
      1. Web application architecture
        1. Workflow of Spring WebFlux
      2. Requirements of the Bloggest system
        1. The use case diagram 
    3. Using Spring Data Elasticsearch for persistence
      1. Understanding Elasticsearch
      2. Understanding Spring Data Elasticsearch
      3. Class diagram for the domain model
      4. Implementation of the domain model using Spring Data Elasticsearch annotations
        1. Setting up dependencies and configuration classes
        2. Implementing the domain model
      5. Implementation of Spring Data Elasticsearch repositories
    4. Using Apache FreeMarker for the view
      1. Understanding template engines
      2. Apache FreeMarker
      3. UI design for Bloggest
      4. UI implementation for Bloggest using Apache FreeMarker
        1. Implementing a common layout using Apache FreeMarker
        2. Implementing a List Articles page
        3. Implementing a Create Article page
        4. Implementing a Show Article page
        5. Implementing an error page
    5. Using Spring WebFlux for controller
      1. Implementation of controllers
      2. Implementation of ControllerAdvice
    6. Using Spring Security for authentication and authorization
    7. Demonstrating Bloggest
    8. Summary
    9. Questions
    10. Further reading
  10. Introduction to Kotlin
    1. Technical requirements
    2. Getting started with Kotlin
      1. Default imports
      2. Basic data types
        1. Numeric data types
        2. Learning numeric literals
        3. Numeric representation
        4. Numeric operations
        5. String literals
      3. The syntax for Kotlin code
        1. The Kotlin packages
        2. String interpolation
        3. Functions in Kotlin
        4. Variables in Kotlin
        5. Conditional statements
          1. The if statement
          2. The when statement 
        6. Type checking and automatic casting
        7. Nullable values and compile-time null safety 
        8. The for loop
          1. The for loop with an array
          2. The for loop with a collection
          3. The for loop with a value range
        9. The while loop
    3. Object-oriented programming with Kotlin
      1. Learning about visibility modifiers
      2. Classes in Kotlin
        1. Abstract classes
        2. Concrete classes
      3. The concept of interfaces in Kotlin
      4. Learning about extensions
      5. Generic types in Kotlin
      6. Enums in Kotlin
      7. Objects in Kotlin
        1. Object expressions
        2. Object declarations
        3. Companion objects
    4. Advanced programming with Kotlin
      1. Functions
        1. Infix notation in functions
        2. Local functions in Kotlin
        3. Default arguments in functions
        4. Named arguments in functions
        5. Generics in functions
        6. Variable number of arguments (vararg) in functions
    5. Summary
    6. Questions
    7. Further reading
  11. Building a Reactive Movie Rating API Using Kotlin
    1. Technical requirements
    2. Getting started
      1. REST architecture
      2. Requirements of REST architecture
        1. The use case diagram
    3. Using Spring Data MongoDB for persistence
      1. Understanding MongoDB 
      2. Understanding Spring Data MongoDB
      3. Class diagram for the domain model
      4. Implementation of the domain model using Spring Data MongoDB annotations
        1. Setting up dependencies and configuration
        2. Implementing the domain model
      5. Implementing of Spring Data MongoDB repositories
      6. Using a service to encapsulate business logic
      7. Testing Services
    4. Using Spring WebFlux for controllers
      1. Implementation of controllers
      2. Testing controllers
    5. Using Spring Security for basic authorization
    6. Demonstrating Moviee
      1. Integration testing
      2. Demonstrating the use of Postman
        1. Accessing the List Movies endpoint
        2. Accessing the Get Movie endpoint
        3. Accessing the Get Movie endpoint with an invalid Movie ID
        4. Accessing the Rate Movie endpoint
    7. Summary
    8. Questions
    9. Further reading
  12. Building an API with Reactive Microservices
    1. Technical requirements
    2. Getting started
      1. Microservices architecture
      2. The requirements of microservices architecture
        1. The use case diagram
        2. The project structure to develop microservices
    3. Using Spring Data Redis for persistence
      1. Understanding Redis
      2. Understanding Spring Data Redis
      3. Class diagram for the domain model
      4. Implementation of domain model using Spring Data Redis annotations
        1. Setting up dependencies and configuration
        2.  Implementing the domain model
      5. Implementation of Spring Data Redis repositories
      6. Using a Service to encapsulate business logic 
    4. Using Spring WebFlux for a controller
      1. Implementation of controllers
    5. Using asynchronous data transfer for cross-microservice communication
      1. Asynchronous data transfer using Redis
    6. Using Docker to support microservices
      1. Understanding Docker
      2. Using Maven to build Docker images
      3. Building a system of microservices with Docker
      4. Deploying microservices with Docker
    7. Demonstrating Saber
      1. Submitting to the Register Taxi endpoint
      2. Submitting location to update Taxi Location endpoint
      3. Submitting to Update Taxi Status endpoint
      4. Accessing the Get Taxi Status endpoint
      5. Accessing the GET available Taxis endpoint
      6. Submitting to Book Taxi endpoint
      7. Submitting to Accept Taxi Booking endpoint
      8. Submitting to cancel Taxi Booking endpoint
      9. Accessing Taxi Bookings endpoint
    8. Summary 
    9. Questions
    10. Further reading
  13. Building a Twitter Clone with Spring Boot
    1. Technical requirements
    2. Getting started
      1. Beginning with the Tweety architecture
      2. Tweety requirements
        1. The use case diagram
    3. Using Spring Data JPA for persistence
      1. Class diagram for the domain model
      2. Implementation of the domain model using Spring Data JPA annotations
        1. Setting up dependencies and configuration
        2. Implementing the domain model
      3. Implementing Spring Data JPA repositories
        1. Caveat for going reactive with blocking JDBC 
      4. Using Service to encapsulate business logic 
    4. Using Angular 5 for the frontend
      1. Getting started with Angular 5 application development
      2. Generating Angular services
        1. Generating the users service
      3. Generating Angular page components
        1. Generating the Tweets Add page
        2. Generating the User Profile page
    5. Using Spring Web Flux for the REST controller
      1. Implementing controllers
      2. Enabling Angular frontend access to controllers
    6. Using Spring Security for authentication and authorization
      1. Understanding OAuth2 
      2. Setting up dependencies and configuration
        1. Configuring the Resource Server
        2. Configuring the Authorization Server
        3. Configuring web security
        4. Using an Angular service for OAuth2 authentication and authorization
    7. Demonstrating Tweety
      1. Accessing the login page
      2. Accessing the List Tweets page
      3. Accessing the Send Tweet page
      4. Accessing the User Profile page
    8. Summary
    9. Questions
    10. Further reading
  14. Introducing Spring Boot 2.0 Asynchronous
    1. Technical requirements
    2. Getting started
      1. Synchronous applications
      2. Asynchronous applications
      3. The requirement of asynchronous applications
        1. The use case diagram
      4. The architecture of an image resizing application
    3. Using Spring Kafka for communication
      1. Understanding Apache Kafka
      2. Setting up dependencies and configuration
      3. Configuration for the Image Resize Request Producer
      4. Configuration for Image Resize Request Consumer
      5. Starting Spring Boot applications in a non-web mode
    4. Using Quartz for scheduling
      1. Understanding Quartz
      2. Setting up dependencies and configuration
      3. Configuration for Quartz scheduling
    5. Demonstrating Image Resizer
      1. Building all dependencies 
      2. Running Apache Kafka
        1. Running Apache ZooKeeper on Windows
        2. Running Apache Kafka on Linux/Unix
        3. Running Apache Kafka on Windows
      3. Running Image Resize Request Consumer
      4. Running Image Resize Request Producer
    6. Summary
    7. Questions
    8. Further reading
  15. Building an Asynchronous Email Formatter
    1. Technical requirements
    2. Getting started
      1. Why Email Formatter is useful
        1. The use case diagram
      2. The architecture of the Email Formatter application
    3. Using Spring Data JPA for persistence
      1. Class diagram for the domain model
      2. Implementation of the domain model using JPA annotations
        1. Setting up dependencies and the configuration class
        2. Implementing the domain model
      3. Implementation of Spring Data JPA repositories
      4. Using Services to encapsulate business logic
    4. Using Apache FreeMarker for templates
    5. Using Spring Kafka for communication
      1. Setting up dependencies and the configuration class
      2. Configuration for User Registration
      3. Configuration for the Email Formatter consumer
        1. Configuring Java Mail
    6. Using Spring Web MVC for the REST controller
      1. Implementation of controller annotations
    7. Using Spring Security for authentication and authorization
    8. Demonstrating Email Formatter
      1. Building all dependencies 
      2. Running Apache Kafka
        1. Running Apache ZooKeeper on Windows
        2. Running Apache Kafka on Linux/Unix
        3. Running Apache Kafka on Windows
      3. Running SMTP server
      4. Running the Email Formatter consumer
      5. Running the User Registration microservice
    9. Summary
    10. Questions
    11. Further reading
  16. Assessments
    1. Chapter 1, Introduction
    2. Chapter 2, Building a Basic Web Application
    3. Chapter 3, Building a Simple Blog Management System
    4. Chapter 4, Introduction to Kotlin
    5. Chapter 5, Building a Reactive Movie Rating API Using Kotlin
    6. Chapter 6, Building an API with Reactive Microservices
    7. Chapter 7, Building a Twitter Clone with Spring Boot
    8. Chapter 8, Introducing Spring Boot 2.0 Asynchronous
    9. Chapter 9, Building an Asynchronous Email Formatter
  17. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
18.117.182.179