Spring Boot: Up and Running

Book description

With over 75 million downloads per month, Spring Boot is the most widely used Java framework available. Its ease and power have revolutionized application development from monoliths to microservices. Yet Spring Boot's simplicity can also be confounding. How do developers learn enough to be productive immediately? This practical book shows you how to use this framework to write successful mission-critical applications.

Mark Heckler from VMware, the company behind Spring, guides you through Spring Boot's architecture and approach, covering topics such as debugging, testing, and deployment. If you want to develop cloud native Java or Kotlin applications with Spring Boot rapidly and effectively (using reactive programming, building APIs, and creating database access of all kinds) this book is for you.

  • Learn how Spring Boot simplifies cloud native application development and deployment
  • Build reactive applications and extend communication across the network boundary to create distributed systems
  • Understand how Spring Boot's architecture and approach increase developer productivity and application portability
  • Deploy Spring Boot applications for production workloads rapidly and reliably
  • Monitor application and system health for optimal performance and reliability
  • Debug, test, and secure cloud-based applications painlessly

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Welcome
    2. Conventions Used in This Book
    3. Using Code Examples
    4. O’Reilly Online Learning
    5. How to Contact Us
    6. Acknowledgments
  2. 1. Spring Boot in a Nutshell
    1. Spring Boot’s Three Foundational Features
      1. Starters for Simplified Dependency Management
      2. Executable JARs for Simplified Deployment
      3. Autoconfiguration
    2. Summary
  3. 2. Choosing Your Tools and Getting Started
    1. Maven or Gradle?
      1. Apache Maven
      2. Gradle
      3. Choosing Between Maven and Gradle
    2. Java or Kotlin?
      1. Java
      2. Kotlin
      3. Choosing Between Java and Kotlin
    3. Choosing a Version of Spring Boot
    4. The Spring Initializr
    5. Straight Outta Commandline
    6. Staying In Integrated Development Environments (IDEs)
    7. Cruising Down main()
    8. Summary
  4. 3. Creating Your First Spring Boot REST API
    1. The Hows and Whys of APIs
    2. What Is REST, and Why Does It Matter?
    3. Your API, HTTP Verb Style
      1. Back to the Initializr
      2. Creating a Simple Domain
    4. GET-ting
      1. @RestController in a Nutshell
      2. POST-ing
      3. PUT-ting
      4. DELETE-ing
      5. And More
    5. Trust, but Verify
    6. Summary
  5. 4. Adding Database Access to Your Spring Boot App
    1. Priming Autoconfig for Database Access
    2. What Do We Hope to Gain?
      1. Adding a Database Dependency
      2. Adding Code
    3. Saving and Retrieving Data
    4. A Bit of Polishing
    5. Summary
  6. 5. Configuring and Inspecting Your Spring Boot App
    1. Application Configuration
      1. @Value
      2. @ConfigurationProperties
      3. Potential Third-Party Option
    2. Autoconfiguration Report
    3. Actuator
      1. Getting Actuator to Open Up
      2. Becoming More Environmentally Aware Using Actuator
      3. Turning Up the Volume on Logging with Actuator
    4. Summary
  7. 6. Really Digging into Data
    1. Defining Entities
    2. Template Support
    3. Repository Support
    4. @Before
    5. Creating a Template-Based Service Using Redis
      1. Initializing the Project
      2. Developing the Redis Service
    6. Converting from Template to Repository
    7. Creating a Repository-Based Service Using the Java Persistence API (JPA)
      1. Initializing the Project
      2. Developing the JPA (MySQL) Service
      3. Loading Data
    8. Creating a Repository-Based Service Using a NoSQL Document Database
      1. Initializing the Project
      2. Developing the MongoDB Service
    9. Creating a Repository-Based Service Using a NoSQL Graph Database
      1. Initializing the Project
      2. Developing the Neo4j Service
    10. Summary
  8. 7. Creating Applications Using Spring MVC
    1. Spring MVC: What Does It Mean?
    2. End User Interactions Using Template Engines
      1. Initializing the Project
      2. Developing the Aircraft Positions Application
    3. Passing Messages
      1. Powering Up PlaneFinder
      2. Extending the Aircraft Positions Application
    4. Creating Conversations with WebSocket
      1. What Is WebSocket?
      2. Refactoring the Aircraft Positions Application
    5. Summary
  9. 8. Reactive Programming with Project Reactor and Spring WebFlux
    1. Introduction to Reactive Programming
    2. Project Reactor
    3. Tomcat versus Netty
    4. Reactive Data Access
      1. R2DBC with H2
    5. Reactive Thymeleaf
    6. RSocket for Fully Reactive Interprocess Communication
      1. What Is RSocket?
      2. Putting RSocket to Work
    7. Summary
  10. 9. Testing Spring Boot Applications for Increased Production Readiness
    1. Unit Testing
    2. Introducing @SpringBootTest
      1. Important Unit Tests for the Aircraft Positions Application
      2. Refactoring for Better Testing
    3. Testing Slices
    4. Summary
  11. 10. Securing Your Spring Boot Application
    1. Authentication and Authorization
      1. Authentication
      2. Authorization
    2. Spring Security in a Nutshell
      1. The HTTP Firewall
      2. Security Filter Chains
      3. Request and Response Headers
    3. Implementing Forms-Based Authentication and Authorization with Spring Security
      1. Adding Spring Security Dependencies
      2. Adding Authentication
      3. Authorization
    4. Implementing OpenID Connect and OAuth2 for Authentication and Authorization
      1. Aircraft Positions Client Application
      2. PlaneFinder Resource Server
    5. Summary
  12. 11. Deploying Your Spring Boot Application
    1. Revisiting the Spring Boot Executable JAR
      1. Building a “Fully Executable” Spring Boot JAR
      2. What Does It Mean?
    2. Exploding JARs
    3. Deploying Spring Boot Applications to Containers
      1. Creating a Container Image from an IDE
      2. Creating a Container Image from the Command Line
      3. Verifying the Image Exists
      4. Running the Containerized Application
    4. Utilities for Examining Spring Boot Application Container Images
      1. Pack
      2. Dive
    5. Summary
  13. 12. Going Deeper with Reactive
    1. When Reactive?
    2. Testing Reactive Applications
      1. But First, Refactoring
      2. And Now, the Testing
    3. Diagnosing and Debugging Reactive Applications
      1. Hooks.onOperatorDebug()
      2. Checkpoints
      3. ReactorDebugAgent.init()
    4. Summary
  14. Index
  15. About the Author

Product information

  • Title: Spring Boot: Up and Running
  • Author(s): Mark Heckler
  • Release date: February 2021
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492076988