Spring in Action, Sixth Edition

Book description

If you need to learn Spring, look no further than this widely beloved and comprehensive guide! Fully revised for Spring 5.3, and packed with interesting real-world examples to get your hands dirty with Spring.

In Spring in Action, 6th Edition you will learn:

  • Building reactive applications
  • Relational and NoSQL databases
  • Integrating via HTTP and REST-based services, and sand reactive RSocket services
  • Reactive programming techniques
  • Deploying applications to traditional servers and containers
  • Securing applications with Spring Security

Over the years, Spring in Action has helped tens of thousands of developers get a major productivity boost from Spring. This new edition of the classic bestseller covers all of the new features of Spring 5.3 and Spring Boot 2.4 along with examples of reactive programming, Spring Security for REST Services, and bringing reactivity to your databases. You'll also find the latest Spring best practices, including Spring Boot for application setup and configuration.

About the Technology
Spring is the required knowledge for Java developers! Why? This powerful framework eliminates a lot of the tedious configuration and repetitive coding tasks, making it easy to build enterprise-ready, production-quality software. The latest updates bring huge productivity boosts to microservices, reactive development, and other modern application designs. It’s no wonder over half of all Java developers use Spring.

About the Book
Spring in Action, Sixth Edition is a comprehensive guide to Spring’s core features, all explained in Craig Walls’ famously clear style. You’ll put Spring into action as you build a complete database-backed web app step-by-step. This new edition covers both Spring fundamentals and new features such as reactive flows, Kubernetes integration, and RSocket. Whether you’re new to Spring or leveling up to Spring 5.3, make this classic bestseller your bible!

What's Inside
  • Relational and NoSQL databases
  • Integrating via RSocket and REST-based services
  • Reactive programming techniques
  • Deploying applications to traditional servers and containers


About the Reader
For beginning to intermediate Java developers.

About the Author
Craig Walls is an engineer at VMware, a member of the Spring engineering team, a popular author, and a frequent conference speaker.

We interviewed Craig as a part of our Six Questions series. Check it out here.



Quotes
The only book you’ll ever need to learn and master the Spring ecosystem. This update is a must-read.
- Pierre-Michel Ansel, 8x8

The best resource for modern Spring development.
- Becky Huett, Big Shovel Labs

The definitive guide for developers wanting to build reliable, fault-tolerant, and scalable cloud-native applications using Spring.
- David Witherspoon, Parsons

Spring is still thriving! Get this latest edition to keep growing with it.
- Kevin Liao, Sotheby’s

Your fast track for Spring Boot development.
- David Torrubia Iñigo, MÁSMÓVIL Group

Publisher resources

View/Submit Errata

Table of contents

  1. Spring in Action
  2. Copyright
  3. From the fifth edition of Spring in Action by Craig Walls
  4. brief contents
  5. contents
  6. front matter
    1. preface
    2. acknowledgments
    3. about this book
      1. Who should read this book
      2. How this book is organized: A roadmap
      3. About the code
      4. Book forum
      5. Other online resources
    4. about the author
    5. about the cover illustration
  7. Part 1. Foundational Spring
  8. 1 Getting started with Spring
    1. 1.1 What is Spring?
    2. 1.2 Initializing a Spring application
      1. 1.2.1 Initializing a Spring project with Spring Tool Suite
      2. 1.2.2 Examining the Spring project structure
    3. 1.3 Writing a Spring application
      1. 1.3.1 Handling web requests
      2. 1.3.2 Defining the view
      3. 1.3.3 Testing the controller
      4. 1.3.4 Building and running the application
      5. 1.3.5 Getting to know Spring Boot DevTools
      6. 1.3.6 Let’s review
    4. 1.4 Surveying the Spring landscape
      1. 1.4.1 The core Spring Framework
      2. 1.4.2 Spring Boot
      3. 1.4.3 Spring Data
      4. 1.4.4 Spring Security
      5. 1.4.5 Spring Integration and Spring Batch
      6. 1.4.6 Spring Cloud
      7. 1.4.7 Spring Native
    5. Summary
  9. 2 Developing web applications
    1. 2.1 Displaying information
      1. 2.1.1 Establishing the domain
      2. 2.1.2 Creating a controller class
      3. 2.1.3 Designing the view
    2. 2.2 Processing form submission
    3. 2.3 Validating form input
      1. 2.3.1 Declaring validation rules
      2. 2.3.2 Performing validation at form binding
      3. 2.3.3 Displaying validation errors
    4. 2.4 Working with view controllers
    5. 2.5 Choosing a view template library
      1. 2.5.1 Caching templates
    6. Summary
  10. 3 Working with data
    1. 3.1 Reading and writing data with JDBC
      1. 3.1.1 Adapting the domain for persistence
      2. 3.1.2 Working with JdbcTemplate
      3. 3.1.3 Defining a schema and preloading data
      4. 3.1.4 Inserting data
    2. 3.2 Working with Spring Data JDBC
      1. 3.2.1 Adding Spring Data JDBC to the build
      2. 3.2.2 Defining repository interfaces
      3. 3.2.3 Annotating the domain for persistence
      4. 3.2.4 Preloading data with CommandLineRunner
    3. 3.3 Persisting data with Spring Data JPA
      1. 3.3.1 Adding Spring Data JPA to the project
      2. 3.3.2 Annotating the domain as entities
      3. 3.3.3 Declaring JPA repositories
      4. 3.3.4 Customizing repositories
    4. Summary
  11. 4 Working with nonrelational data
    1. 4.1 Working with Cassandra repositories
      1. 4.1.1 Enabling Spring Data Cassandra
      2. 4.1.2 Understanding Cassandra data modeling
      3. 4.1.3 Mapping domain types for Cassandra persistence
      4. 4.1.4 Writing Cassandra repositories
    2. 4.2 Writing MongoDB repositories
      1. 4.2.1 Enabling Spring Data MongoDB
      2. 4.2.2 Mapping domain types to documents
      3. 4.2.3 Writing MongoDB repository interfaces
    3. Summary
  12. 5 Securing Spring
    1. 5.1 Enabling Spring Security
    2. 5.2 Configuring authentication
      1. 5.2.1 In-memory user details service
      2. 5.2.2 Customizing user authentication
    3. 5.3 Securing web requests
      1. 5.3.1 Securing requests
      2. 5.3.2 Creating a custom login page
      3. 5.3.3 Enabling third-party authentication
      4. 5.3.4 Preventing cross-site request forgery
    4. 5.4 Applying method-level security
    5. 5.5 Knowing your user
    6. Summary
  13. 6 Working with configuration properties
    1. 6.1 Fine-tuning autoconfiguration
      1. 6.1.1 Understanding Spring’s environment abstraction
      2. 6.1.2 Configuring a data source
      3. 6.1.3 Configuring the embedded server
      4. 6.1.4 Configuring logging
      5. 6.1.5 Using special property values
    2. 6.2 Creating your own configuration properties
      1. 6.2.1 Defining configuration property holders
      2. 6.2.2 Declaring configuration property metadata
    3. 6.3 Configuring with profiles
      1. 6.3.1 Defining profile-specific properties
      2. 6.3.2 Activating profiles
      3. 6.3.3 Conditionally creating beans with profiles
    4. Summary
  14. Part 2. Integrated Spring
  15. 7 Creating REST services
    1. 7.1 Writing RESTful controllers
      1. 7.1.1 Retrieving data from the server
      2. 7.1.2 Sending data to the server
      3. 7.1.3 Updating data on the server
      4. 7.1.4 Deleting data from the server
    2. 7.2 Enabling data-backed services
      1. 7.2.1 Adjusting resource paths and relation names
      2. 7.2.2 Paging and sorting
    3. 7.3 Consuming REST services
      1. 7.3.1 GETting resources
      2. 7.3.2 PUTting resources
      3. 7.3.3 DELETEing resources
      4. 7.3.4 POSTing resource data
    4. Summary
  16. 8 Securing REST
    1. 8.1 Introducing OAuth 2
    2. 8.2 Creating an authorization server
    3. 8.3 Securing an API with a resource server
    4. 8.4 Developing the client
    5. Summary
  17. 9 Sending messages asynchronously
    1. 9.1 Sending messages with JMS
      1. 9.1.1 Setting up JMS
      2. 9.1.2 Sending messages with JmsTemplate
      3. 9.1.3 Receiving JMS messages
    2. 9.2 Working with RabbitMQ and AMQP
      1. 9.2.1 Adding RabbitMQ to Spring
      2. 9.2.2 Sending messages with RabbitTemplate
      3. 9.2.3 Receiving messages from RabbitMQ
    3. 9.3 Messaging with Kafka
      1. 9.3.1 Setting up Spring for Kafka messaging
      2. 9.3.2 Sending messages with KafkaTemplate
      3. 9.3.3 Writing Kafka listeners
    4. Summary
  18. 10 Integrating Spring
    1. 10.1 Declaring a simple integration flow
      1. 10.1.1 Defining integration flows with XML
      2. 10.1.2 Configuring integration flows in Java
      3. 10.1.3 Using Spring Integration’s DSL configuration
    2. 10.2 Surveying the Spring Integration landscape
      1. 10.2.1 Message channels
      2. 10.2.2 Filters
      3. 10.2.3 Transformers
      4. 10.2.4 Routers
      5. 10.2.5 Splitters
      6. 10.2.6 Service activators
      7. 10.2.7 Gateways
      8. 10.2.8 Channel adapters
      9. 10.2.9 Endpoint modules
    3. 10.3 Creating an email integration flow
    4. Summary
  19. Part 3. Reactive Spring
  20. 11 Introducing Reactor
    1. 11.1 Understanding reactive programming
      1. 11.1.1 Defining Reactive Streams
    2. 11.2 Getting started with Reactor
      1. 11.2.1 Diagramming reactive flows
      2. 11.2.2 Adding Reactor dependencies
    3. 11.3 Applying common reactive operations
      1. 11.3.1 Creating reactive types
      2. 11.3.2 Combining reactive types
      3. 11.3.3 Transforming and filtering reactive streams
      4. 11.3.4 Performing logic operations on reactive types
    4. Summary
  21. 12 Developing reactive APIs
    1. 12.1 Working with Spring WebFlux
      1. 12.1.1 Introducing Spring WebFlux
      2. 12.1.2 Writing reactive controllers
    2. 12.2 Defining functional request handlers
    3. 12.3 Testing reactive controllers
      1. 12.3.1 Testing GET requests
      2. 12.3.2 Testing POST requests
      3. 12.3.3 Testing with a live server
    4. 12.4 Consuming REST APIs reactively
      1. 12.4.1 GETting resources
      2. 12.4.2 Sending resources
      3. 12.4.3 Deleting resources
      4. 12.4.4 Handling errors
      5. 12.4.5 Exchanging requests
    5. 12.5 Securing reactive web APIs
      1. 12.5.1 Configuring reactive web security
      2. 12.5.2 Configuring a reactive user details service
    6. Summary
  22. 13 Persisting data reactively
    1. 13.1 Working with R2DBC
      1. 13.1.1 Defining domain entities for R2DBC
      2. 13.1.2 Defining reactive repositories
      3. 13.1.3 Testing R2DBC repositories
      4. 13.1.4 Defining an OrderRepository aggregate root service
    2. 13.2 Persisting document data reactively with MongoDB
      1. 13.2.1 Defining domain document types
      2. 13.2.2 Defining reactive MongoDB repositories
      3. 13.2.3 Testing reactive MongoDB repositories
    3. 13.3 Reactively persisting data in Cassandra
      1. 13.3.1 Defining domain classes for Cassandra persistence
      2. 13.3.2 Creating reactive Cassandra repositories
      3. 13.3.3 Testing reactive Cassandra repositories
    4. Summary
  23. 14 Working with RSocket
    1. 14.1 Introducing RSocket
    2. 14.2 Creating a simple RSocket server and client
      1. 14.2.1 Working with request-response
      2. 14.2.2 Handling request-stream messaging
      3. 14.2.3 Sending fire-and-forget messages
      4. 14.2.4 Sending messages bidirectionally
    3. 14.3 Transporting RSocket over WebSocket
    4. Summary
  24. Part 4. Deployed Spring
  25. 15 Working with Spring Boot Actuator
    1. 15.1 Introducing Actuator
      1. 15.1.1 Configuring Actuator’s base path
      2. 15.1.2 Enabling and disabling Actuator endpoints
    2. 15.2 Consuming Actuator endpoints
      1. 15.2.1 Fetching essential application information
      2. 15.2.2 Viewing configuration details
      3. 15.2.3 Viewing application activity
      4. 15.2.4 Tapping runtime metrics
    3. 15.3 Customizing Actuator
      1. 15.3.1 Contributing information to the /info endpoint
      2. 15.3.2 Defining custom health indicators
      3. 15.3.3 Registering custom metrics
      4. 15.3.4 Creating custom endpoints
    4. 15.4 Securing Actuator
    5. Summary
  26. 16 Administering Spring
    1. 16.1 Using Spring Boot Admin
      1. 16.1.1 Creating an Admin server
      2. 16.1.2 Registering Admin clients
    2. 16.2 Exploring the Admin server
      1. 16.2.1 Viewing general application health and information
      2. 16.2.2 Watching key metrics
      3. 16.2.3 Examining environment properties
      4. 16.2.4 Viewing and setting logging levels
    3. 16.3 Securing the Admin server
      1. 16.3.1 Enabling login in the Admin server
      2. 16.3.2 Authenticating with the Actuator
    4. Summary
  27. 17 Monitoring Spring with JMX
    1. 17.1 Working with Actuator MBeans
    2. 17.2 Creating your own MBeans
    3. 17.3 Sending notifications
    4. Summary
  28. 18 Deploying Spring
    1. 18.1 Weighing deployment options
    2. 18.2 Building executable JAR files
    3. 18.3 Building container images
      1. 18.3.1 Deploying to Kubernetes
      2. 18.3.2 Enabling graceful shutdown
      3. 18.3.3 Working with application liveness and readiness
    4. 18.4 Building and deploying WAR files
    5. 18.5 The end is where we begin
    6. Summary
  29. Appendix. Bootstrapping Spring applications
    1. A.1 Initializing a project with Spring Tool Suite
    2. A.2 Initializing a project with IntelliJ IDEA
    3. A.3 Initializing a project with NetBeans
    4. A.4 Initializing a project at start.spring.io
    5. A.5 Initializing a project from the command line
      1. curl and the Initializr API
      2. Spring Boot command-line interface
    6. A.6 Building and running projects
  30. index

Product information

  • Title: Spring in Action, Sixth Edition
  • Author(s): Craig Walls
  • Release date: March 2022
  • Publisher(s): Manning Publications
  • ISBN: 9781617297571