Creating Spring Boot Microservices
3h 16mIntermediate2024-06-17
Authors

Mary Ellen Bowman
25+ years of full life-cycle software development experience
Course details
If you’re looking for a practical introduction on creating Spring Boot microservices, this course was designed just for you. Join instructor and software developer Mary Ellen Bowman as she provides a skills-based, intermediate-level overview on how to create microservices using the power of Spring Boot 3. Along the way, discover several other related technologies and frameworks such as Spring Data, Spring Data REST, Spring MVC, JUnit, Mockito, SpringBootTest, Docker, MongoDB, Spring Security, and Spring Cloud.
Skills covered
Spring BootSoftware ArchitectureWeb Development ToolsWeb DevelopmentOpen SourceSoftware DevelopmentOne-Off
Concepts
Introduction
- Build a RESTful Spring Boot microservice
- What you should know
- How to use the exercise files
Spring Framework Introduction
- Inversion of control pattern
- Spring ApplicationContext and Spring Beans
- Spring autowiring annotations
- Challenge
- Solution
Create a Spring Boot Microservice
- Introduction to Spring Initializr
- Project setup
- Build, deploy, and launch the microservice
- Challenge - Add the Actuator dependency
- Solution - Add the Actuator dependency
Leverage Spring-Data-JPA Repository Interfaces
- The domain model
- The persistence entities
- Declare JPA repositories
- Spring Data JPA repository dependency injection
- Invoking the repositories
- Introduction to Spring Data query methods
- Challenge - Create a JPQL query method
- Solution - Create a JPQL query method
Expose RESTful API's with Spring Data REST
- Create APIs with Spring Data REST
- Mapping API endpoints to repositories
- Override default behavior
- Swagger UI
- Challenge - Modify the URL repository keyword
- Solution - Modify the URL repository keyword
Expose RESTful API's with Spring MVC
- Choosing the right framework
- Declaring a new RestController
- Create the RestController HTTP POST endpoint
- Create the RestController HTTP GET endpoint
- Create the RestController HTTP PUT, PATCH, and DELETE endpoints
- Challenge - Add a PATCH endpoint
- Solution - Add a PATCH endpoint
Best Practices
- Global exception handling
- Transaction rollback
- Add a runtime logger
- JUnit, Mockito, and SpringBootTest
- API documentation
Dockerized Microservices and Databases
- Why Docker
- Dockerizing a microservice
- Spring Boot Docker Compose
- Database versioning with Flyway migrate
Create a RESTful MongoDB Microservice
- Use cases for an image microservice
- Challenge - Create the Spring Boot MongoDB project
- Solution - Create the Spring Boot MongoDB project
- Image file upload microservice
- Spring Data MongoDB documents and repositories
Create an API Gateway with Spring Cloud
- Use cases for an API gateway microservice
- Routing to the JPA microservice
- Routing to the MongoDB microservice
- Add Spring Security to the gateway
- Orchestrate with Docker Compose
- Cleaning up the workspace
Conclusion
- Next steps