Spring: Microservices with Spring Boot

Book Description

Unlock the power of Spring Boot to build and deploy production-ready microservices

About This Book

  • Get to know the advanced features of Spring Boot in order to develop and monitor applications
  • Use Spring cloud to deploy and manage microservices on the cloud
  • Look at embedded servers and deploy a test application to a PaaS Cloud platform
  • Embedded with assessments that will help you revise the concepts you have learned in this book

Who This Book Is For

This book is aimed at Java developers who knows the basics of Spring programming and want to build microservices with Spring Boot.

What You Will Learn

  • Use Spring Initializr to create a basic spring project
  • Build a basic microservice with Spring Boot
  • Implement caching and exception handling
  • Secure your microservice with Spring security and OAuth2
  • Deploy microservices using self-contained HTTP server
  • Monitor your microservices with Spring Boot actuator
  • Learn to develop more effectively with developer tools

In Detail

Microservices helps in decomposing applications into small services and move away from a single monolithic artifact. It helps in building systems that are scalable, flexible, and high resilient. Spring Boot helps in building REST-oriented, production-grade microservices.

This book is a quick learning guide on how to build, monitor, and deploy microservices with Spring Boot. You'll be first familiarized with Spring Boot before delving into building microservices. You will learn how to document your microservice with the help of Spring REST docs and Swagger documentation. You will then learn how to secure your microservice with Spring Security and OAuth2. You will deploy your app using a self-contained HTTP server and also learn to monitor a microservice with the help of Spring Boot actuator.

This book is ideal for Java developers who knows the basics of Spring programming and want to build microservices with Spring Boot.

This book is embedded with useful assessments that will help you revise the concepts you have learned in this book.

Style and approach

This book follows a practical approach to teach you how to build, monitor, and deploy microservices with Spring Boot.

Note: This book is a blend of text and quizzes, all packaged up keeping your journey in mind. It includes content from the following Packt product:

  • Mastering Spring 5.0 by Ranga Rao Karanam

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.

Publisher Resources

Download Example Code

Table of Contents

  1. Spring: Microservices with Spring Boot
    1. Spring: Microservices with Spring Boot
    2. Credits
      1. Meet Your Expert
    3. Preface
      1. What's in It for Me?
      2. What Will I Get from This Book?
      3. Prerequisites
    4. 1. Building Microservices with Spring Boot
      1. What is Spring Boot?
        1. Building a Quick Prototype for a Microservice
        2. Primary Goals
        3. Nonfunctional Features
      2. Spring Boot Hello World
        1. Configure spring-boot-starter-parent
        2. spring-boot-starter-parent
        3. Configure pom.xml with the Required Starter Projects
          1. Understanding Starter Projects
        4. Configuring spring-boot-maven-plugin
        5. Creating Your First Spring Boot Launch Class
          1. The SpringApplication Class
          2. The @SpringBootApplication Annotation
        6. Running Our Hello World Application
        7. Auto-configuration
        8. Starter Projects
      3. What is REST?
      4. First REST Service
        1. Simple Method Returning String
          1. Unit Testing
          2. Integration Testing
        2. Simple REST Method Returning an Object
          1. Executing a Request
          2. Unit Testing
          3. Integration Testing
        3. Get Method with Path Variables
          1. Executing a Request
          2. Unit Testing
          3. Integration Testing
      5. Creating a Todo Resource
        1. Request Methods, Operations, and Uris
        2. Beans and Services
        3. Retrieving a Todo List
          1. Executing the Service
          2. Unit Testing
          3. Integration Testing
        4. Retrieving Details for a Specific Todo
          1. Executing the Service
          2. Unit Testing
          3. Integration Testing
        5. Adding A Todo
          1. Postman
          2. Executing the POST Service
          3. Unit Testing
          4. Integration Testing
      6. Spring Initializr
        1. Creating Your First Spring Initializr Project
          1. pom.xml
          2. FirstSpringInitializrApplication.java Class
          3. FirstSpringInitializrApplicationTests Class
      7. A Quick Peek into Auto-Configuration
      8. Summary
      9. Assessments
    5. 2. Extending Microservices
      1. Exception Handling
        1. Spring Boot Default Exception Handling
          1. Non-Existent Resource
          2. Resource Throwing an Exception
          3. Throwing a Custom Exception
          4. Customizing the Exception Message
          5. Response Status
      2. HATEOAS
        1. Sending HATEOAS Links in Response
          1. Spring Boot Starter HATEOAS
      3. Validation
        1. Enabling Validation on the Controller Method
        2. Defining validations on the Bean
        3. Unit Testing Validations
      4. Documenting REST Services
        1. Generating a Swagger Specification
          1. Swagger UI
          2. Customizing Swagger Documentation Using Annotations
      5. Securing REST Services with Spring Security
        1. Adding Spring Security Starter
        2. Basic Authentication
          1. Integration Testing
          2. Unit Testing
        3. OAuth 2 Authentication
          1. High-level flow
          2. Implementing OAuth 2 authentication for Our Service
          3. Setting up Authorization and Resource Servers:
        4. Executing OAuth Requests
          1. Obtaining an Access Token
          2. Executing the Request Using the Access Token
          3. Integration Test
      6. Internationalization
      7. Caching
        1. Spring-boot-starter-cache
        2. Enabling Caching
        3. Caching Data
        4. JSR-107 Caching Annotations
          1. Auto-Detection Order
      8. Summary
      9. Assessments
    6. 3. Advanced Spring Boot Features
      1. Externalised Configuration
        1. Customizing Frameworks Through application.properties
          1. Logging
          2. Embedded Server Configuration
          3. Spring MVC
          4. Spring Starter Security
          5. Data Sources, JDBC, and JPA
          6. Other Configuration Options
        2. Custom Properties in Application.Properties
          1. Configuration properties - Type-Safe Configuration Management
        3. Profiles
          1. Profiles-Based Bean Configuration
        4. Other Options for Application Configuration Values
        5. YAML Configuration
      2. Embedded Servers
        1. Switching to Jetty and Undertow
        2. Building a WAR file
      3. Developer Tools
        1. Live Reload
      4. Spring Boot Actuator
        1. HAL Browser
        2. Configuration Properties
        3. Environment Details
        4. Health
        5. Mappings
        6. Beans
        7. Metrics
        8. Auto-Configuration
        9. Debugging
      5. Deploying an Application to Cloud
        1. Cloud Foundry
      6. Summary
      7. Assessments
    7. 4. Assessment Answers
      1. Lesson 1: Building Microservices with Spring Boot
      2. Lesson 2: Extending Microservices
      3. Lesson 3: Advanced Spring Boot Features

Product Information

  • Title: Spring: Microservices with Spring Boot
  • Author(s): Ranga Rao Karanam
  • Release date: March 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789132588