Spring Boot 2.0 Cookbook - Second Edition
豆瓣
Alex Antonov
简介
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.
contents
Title Page
Copyright and Credits
Spring Boot 2.0 Cookbook Second Edition
Dedication
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Sections
Getting ready
How to do it...
How it works...
There's more...
See also
Get in touch
Reviews
Getting Started with Spring Boot
Introduction
Using a Spring Boot template and starter
How to do it...
How it works...
Creating a simple application
How to do it...
How it works...
Launching an application using Gradle
How to do it...
How it works...
Using the command-line runners
How to do it...
How it works...
Setting up a database connection
Getting ready
How to do it...
How it works...
Setting up a data repository service
How to do it...
How it works...
Scheduling executors
Getting ready
How to do it...
How it works...
Configuring Web Applications
Creating a basic RESTful application
How to do it...
How it works...
Creating Spring Data REST service
How to do it...
How it works...
Configuring custom servlet filters
How to do it...
How it works...
Configuring custom interceptors
How to do it...
How it works...
Configuring custom HttpMessageConverters
How to do it...
How it works...
Configuring custom PropertyEditors
How to do it...
How it works...
Configuring custom type formatters
How to do it...
How it works...
Web Framework Behavior Tuning
Introduction
Configuring route matching patterns
How to do it...
How it works...
Configuring custom static path mappings
How to do it...
How it works...
Tuning Tomcat via ServletWebServerFactory
How to do it...
How it works...
Choosing embedded servlet containers
How to do it...
How it works...
Adding custom connectors
Getting ready
How to do it...
How it works...
Writing Custom Spring Boot Starters
Introduction
Understanding Spring Boot autoconfiguration
How to do it...
How it works...
Creating a custom Spring Boot autoconfiguration starter
How to do it...
How it works...
Configuring custom conditional bean instantiations
How to do it...
How it works...
Using custom @Enable annotations to toggle configuration
How to do it...
How it works...
Application Testing
Introduction
Creating tests for MVC controllers
How to do it...
How it works...
Configuring a database schema and populating it
How to do it...
How it works...
Initializing the database with Spring JPA and Hibernate
Initializing the database with Spring JDBC
Creating tests using an in-memory database
How to do it...
How it works...
Creating tests using mock objects
How to do it...
How it works...
Creating a JPA component test
How to do it...
How it works...
Creating a WebMvc component test
How to do it...
How it works...
Writing tests using Cucumber
How to do it...
How it works...
Writing tests using Spock
How to do it...
How it works...
Application Packaging and Deployment
Introduction
Creating a Spring Boot executable JAR
How to do it...
How it works...
Creating Docker images
How to do it...
How it works...
Building self-executing binaries
Getting ready
How to do it...
How it works...
Spring Boot environment configuration, hierarchy, and precedence
How to do it...
How it works...
Adding a custom PropertySource to the environment using EnvironmentPostProcessor
How to do it...
How it works...
Externalizing an environmental configuration using property files
How to do it...
How it works...
Externalizing an environmental configuration using environment variables
How to do it...
How it works...
Externalizing an environmental configuration using Java system properties
How to do it...
How it works...
Externalizing an environmental config using JSON
How to do it...
How it works...
Setting up Consul
How to do it...
How it works...
Externalizing an environmental config using Consul and envconsul
Getting ready
How to do it...
How it works...
Health Monitoring and Data Visualization
Introduction
Writing custom health indicators
How to do it...
How it works...
Configuring management context
How to do it...
How it works...
Emitting metrics
Getting ready
How to do it...
How it works...
Monitoring Spring Boot via JMX
Getting ready
How to do it...
How it works...
Managing Spring Boot via SSHd Shell and writing custom remote Shell commands
How to do it...
How it works...
Integrating Micrometer metrics with Graphite
Getting ready
How to do it...
How it works...
Integrating Micrometer metrics with Dashing
Getting ready
How to do it...
How it works...
Spring Boot DevTools
Introduction
Adding Spring Boot DevTools to a project
How to do it...
How it works...
Configuring LiveReload
How to do it...
How it works...
Configuring dynamic application restart triggers
How to do it...
How it works...
Using Remote Update
How to do it...
How it works...
Spring Cloud
Introduction
Getting started with Spring Cloud
How to do it...
How it works...
Service discovery using Spring Cloud Consul
How to do it...
How it works...
Using Spring Cloud Netflix – Feign
How to do it...
How it works...
Service discovery using Spring Cloud Netflix – Eureka
How to do it...
How it works...
Using Spring Cloud Netflix – Hystrix
How to do it...
How it works...
Other Books You May Enjoy
Leave a review - let other readers know what you think