Building Microservices with Spring
Master design patterns of the Spring framework to build smart, efficient microservices
- 502 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Building Microservices with Spring
Master design patterns of the Spring framework to build smart, efficient microservices
About This Book
Learn and use the design patterns and best practices in Spring to solve common design problems and build user-friendly microservices
Key Features
- Study the benefits of using the right design pattern in your toolkit
- Manage your code easily with Spring's dependency injection pattern
- Explore the features of Docker and Mesos to build successful microservices
Book Description
Getting Started with Spring Microservices begins with an overview of the Spring Framework 5.0, its design patterns, and its guidelines that enable you to implement responsive microservices at scale. You will learn how to use GoF patterns in application design. You will understand the dependency injection pattern, which is the main principle behind the decoupling process of the Spring Framework and makes it easier to manage your code. Then, you will learn how to use proxy patterns in aspect-oriented programming and remoting. Moving on, you will understand the JDBC template patterns and their use in abstracting database access.
After understanding the basics, you will move on to more advanced topics, such as reactive streams and concurrency. Written to the latest specifications of Spring that focuses on Reactive Programming, the Learning Path teaches you how to build modern, internet-scale Java applications in no time.
Next, you will understand how Spring Boot is used to deploying serverless autonomous services by removing the need to have a heavyweight application server. You'll also explore ways to deploy your microservices to Docker and managing them with Mesos.
By the end of this Learning Path, you will have the clarity and confidence for implementing microservices using Spring Framework.
This Learning Path includes content from the following Packt products:
- Spring 5 Microservices by Rajesh R V
- Spring 5 Design Patterns by Dinesh Rajput
What you will learn
- Develop applications using dependency injection patterns
- Build web applications using traditional Spring MVC patterns
- Utilize the reactive programming pattern to build reactive web apps
- Learn concurrency and handle multiple connections inside a web server
- Use Spring Boot and Spring Cloud to develop microservices
- Leverage reactive programming to build cloud-native applications
Who this book is for
Getting Started with Spring Microservices is ideal for Spring developers who want to use design patterns to solve common design problems and build cloud-ready, Internet-scale applications, and simple RESTful services.
Frequently asked questions
Information
Building Microservices with Spring Boot
- Setting up the latest Spring development environment
- Developing RESTful services using Spring Framework 5 and Spring Boot
- Building reactive microservices using Spring WebFlux and Spring Messaging
- Securing microservices using Spring Security and OAuth2
- Implementing cross-origin microservices
- Documenting Spring Boot microservices using Swagger
- Spring Boot Actuator for building production-ready microservices
Setting up a development environment
- JDK 1.8 (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
- Spring Tool Suite 3.8.2 (STS) (https://spring.io/tools/sts/all)
- Maven 3.3.1 (https://maven.apache.org/download.cgi)
- Spring Framework 5.0.0.RC1
- Spring Boot 2.0.0. M1
Spring Boot for building RESTful microservices
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
Getting started with Spring Boot
- By using Spring Boot CLI as a command-line tool
- By using IDEs like Spring Tool Suite (STS), which provide Spring Boot, supported out of the box
- By using the Spring Initializr project at http://start.spring.io
- By using SDKMAN! (The Software Development Kit Manager) from http://sdkman.io
Developing a Spring Boot microservice
- Install the Spring Boot command-line tool by downloading the spring-boot-cli-2.0.0.BUILD-M1-bin.zip file from the following location URL:
https://repo.spring.io/milestone/org/springframework/boot/spring-boot-cli/2.0.0.M1/
- Unzip the file into a directory of choice. Open a terminal window, and change the terminal prompt to the bin folder.
- Verify the installation with the following command. If successful, the Spring CLI version will be printed on the console as shown:
$spring –-version
Spring CLI v2.0.0.M1
- As the next step, a quick REST service will be developed in groovy, which is supported out of the box in Spring Boot. To do so, copy and paste the following code using any editor of choice, and save it as myfirstapp.groovy into any folder:
@RestController
class HelloworldController {
@RequestMapping("/")
String sayHello(){
return "Hello World!"
}
}
- In order to run this groovy application, go to the folder where myfirstapp.groovy is saved, and execute the following command. The last few lines of the server startup log will be as shown in the following command snippet:
$spring ...
Table of contents
- Title Page
- Copyright
- About Packt
- Contributors
- Preface
- Getting Started with Spring Framework 5.0 and Design Patterns
- Overview of GOF Design Patterns - Core Design Patterns
- Wiring Beans using the Dependency Injection Pattern
- Spring Aspect Oriented Programming with Proxy and Decorator pattern
- Accessing a Database with Spring and JDBC Template Patterns
- Improving Application Performance Using Caching Patterns
- Implementing Reactive Design Patterns
- Implementing Concurrency Patterns
- Demystifying Microservices
- Related Architecture Styles and Use Cases
- Building Microservices with Spring Boot
- Scale Microservices with Spring Cloud Components
- Logging and Monitoring Microservices
- Containerizing Microservices with Docker
- Scaling Dockerized Microservices with Mesos and Marathon
- Other Books You May Enjoy