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

Spring Boot 2.0 Cookbook - Second Edition

Book Description

Take your application development skills to the next level by implementing Spring Boot features effectively

About This Book

  • This collection of effective recipes serves as guidelines for Spring Boot application development
  • Get up to date with features of the latest version of Spring Boot 2.0
  • Tips and tricks to improve your efficiency through the stages of software development

Who This Book Is For

This book is for Java Developers who have good knowledge and understanding of Spring and Java application development.

What You Will Learn

  • Get to know Spring Boot Starters and create custom auto-configurations
  • Work with custom annotations that enable bean activation
  • Use DevTools to easily develop and debug applications
  • Learn the effective testing techniques by integrating Cucumber and Spock
  • Observe an eternal application configuration using Consul
  • Move your existing Spring Boot applications to the cloud
  • Use Hashicorp Consul and Netflix Eureka for dynamic Service Discovery
  • Understand the various mechanisms that Spring Boot provides to examine an application's health

In Detail

The Spring framework provides great flexibility for Java development, which also results in tedious configuration work. Spring Boot addresses the configuration difficulties of Spring and makes it easy to create standalone, production-grade Spring-based applications.

This practical guide makes the existing development process more efficient. Spring Boot Cookbook 2.0 Second Edition smartly combines all the skills and expertise to efficiently develop, test, deploy, and monitor applications using Spring Boot on premise and in the cloud. We start with an overview of the important Spring Boot features you will learn to create a web application for a RESTful service. Learn to fine-tune the behavior of a web application by learning about custom routes and asset paths and how to modify routing patterns. Address the requirements of a complex enterprise application and cover the creation of custom Spring Boot starters.

This book also includes examples of the new and improved facilities available to create various kinds of tests introduced in Spring Boot 1.4 and 2.0, and gain insights into Spring Boot DevTools. Explore the basics of Spring Boot Cloud modules and various Cloud starters to make applications in “Cloud Native” and take advantage of Service Discovery and Circuit Breakers.

Style and approach

This practical guide follows a recipe-based approach and provides extremely helpful guidelines to build, configure, and customize your Spring Boot applications.

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 Cookbook Second Edition
  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. Sections
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Get in touch
      1. Reviews
  7. Getting Started with Spring Boot
    1. Introduction
    2. Using a Spring Boot template and starter
      1. How to do it...
      2. How it works...
    3. Creating a simple application
      1. How to do it...
      2. How it works...
    4. Launching an application using Gradle
      1. How to do it...
      2. How it works...
    5. Using the command-line runners
      1. How to do it...
      2. How it works...
    6. Setting up a database connection
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Setting up a data repository service
      1. How to do it...
      2. How it works...
    8. Scheduling executors
      1. Getting ready
      2. How to do it...
      3. How it works...
  8. Configuring Web Applications
    1. Creating a basic RESTful application
      1. How to do it...
      2. How it works...
    2. Creating Spring Data REST service
      1. How to do it...
      2. How it works...
    3. Configuring custom servlet filters
      1. How to do it...
      2. How it works...
    4. Configuring custom interceptors
      1. How to do it...
      2. How it works...
    5. Configuring custom HttpMessageConverters
      1. How to do it...
      2. How it works...
    6. Configuring custom PropertyEditors
      1. How to do it...
      2. How it works...
    7. Configuring custom type formatters
      1. How to do it...
      2. How it works...
  9. Web Framework Behavior Tuning
    1. Introduction
    2. Configuring route matching patterns
      1. How to do it...
      2. How it works...
    3. Configuring custom static path mappings
      1. How to do it...
      2. How it works...
    4. Tuning Tomcat via ServletWebServerFactory
      1. How to do it...
      2. How it works...
    5. Choosing embedded servlet containers
      1. How to do it...
      2. How it works...
    6. Adding custom connectors
      1. Getting ready
      2. How to do it...
      3. How it works...
  10. Writing Custom Spring Boot Starters
    1. Introduction
    2. Understanding Spring Boot autoconfiguration
      1. How to do it...
      2. How it works...
    3. Creating a custom Spring Boot autoconfiguration starter
      1. How to do it...
      2. How it works...
    4. Configuring custom conditional bean instantiations
      1. How to do it...
      2. How it works...
    5. Using custom @Enable annotations to toggle configuration
      1. How to do it...
      2. How it works...
  11. Application Testing
    1. Introduction
    2. Creating tests for MVC controllers
      1. How to do it...
      2. How it works...
    3. Configuring a database schema and populating it
      1. How to do it...
      2. How it works...
        1. Initializing the database with Spring JPA and Hibernate
        2. Initializing the database with Spring JDBC
    4. Creating tests using an in-memory database
      1. How to do it...
      2. How it works...
    5. Creating tests using mock objects
      1. How to do it...
      2. How it works...
    6. Creating a JPA component test
      1. How to do it...
      2. How it works...
    7. Creating a WebMvc component test
      1. How to do it...
      2. How it works...
    8. Writing tests using Cucumber
      1. How to do it...
      2. How it works...
    9. Writing tests using Spock
      1. How to do it...
      2. How it works...
  12. Application Packaging and Deployment
    1. Introduction
    2. Creating a Spring Boot executable JAR
      1. How to do it...
      2. How it works...
    3. Creating Docker images
      1. How to do it...
      2. How it works...
    4. Building self-executing binaries
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Spring Boot environment configuration, hierarchy, and precedence
      1. How to do it...
      2. How it works...
    6. Adding a custom PropertySource to the environment using EnvironmentPostProcessor
      1. How to do it...
      2. How it works...
    7. Externalizing an environmental configuration using property files
      1. How to do it...
      2. How it works...
    8. Externalizing an environmental configuration using environment variables
      1. How to do it...
      2. How it works...
    9. Externalizing an environmental configuration using Java system properties
      1. How to do it...
      2. How it works...
    10. Externalizing an environmental config using JSON
      1. How to do it...
      2. How it works...
    11. Setting up Consul
      1. How to do it...
      2. How it works...
    12. Externalizing an environmental config using Consul and envconsul
      1. Getting ready
      2. How to do it...
      3. How it works...
  13. Health Monitoring and Data Visualization
    1. Introduction
    2. Writing custom health indicators
      1. How to do it...
      2. How it works...
    3. Configuring management context
      1. How to do it...
      2. How it works...
    4. Emitting metrics
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Monitoring Spring Boot via JMX
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Managing Spring Boot via SSHd Shell and writing custom remote Shell commands
      1. How to do it...
      2. How it works...
    7. Integrating Micrometer metrics with Graphite
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Integrating Micrometer metrics with Dashing
      1. Getting ready
      2. How to do it...
      3. How it works...
  14. Spring Boot DevTools
    1. Introduction
    2. Adding Spring Boot DevTools to a project
      1. How to do it...
      2. How it works...
    3. Configuring LiveReload
      1. How to do it...
      2. How it works...
    4. Configuring dynamic application restart triggers
      1. How to do it...
      2. How it works...
    5. Using Remote Update
      1. How to do it...
      2. How it works...
  15. Spring Cloud
    1. Introduction
    2. Getting started with Spring Cloud
      1. How to do it...
      2. How it works...
    3. Service discovery using Spring Cloud Consul
      1. How to do it...
      2. How it works...
    4. Using Spring Cloud Netflix – Feign
      1. How to do it...
      2. How it works...
    5. Service discovery using Spring Cloud Netflix – Eureka
      1. How to do it...
      2. How it works...
    6. Using Spring Cloud Netflix – Hystrix
      1. How to do it...
      2. How it works...
  16. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think