Introduction To Spring Training

 

Spring Boot and Microservices – 5 Days

Course Description – Spring Boot and Microservices

This is a comprehensive course in developing Microservices through Spring Boot. It will cover the basics of Spring Dependency Injection and Spring Boot Configurations followed by the development of traditional annotated @RestController and WebFlux RouterFunction services. Students will monitor their services through Spring Boot Admin and test them using various testing techniques prior to Docker Image and Container deployment.

What You Will Learn

  • Use Spring Boot starters to create new applications
  • Understand and use Spring Boot’s auto-configuration
  • Customize the configuration of services
  • Build a simple Controller that can receive request parameters
  • Define Microservices using RestControllers and use Content Negotiation to return JSON or XML Responses
  • Understand and use Spring Boot’s Actuators with Spring Boot Admin to monitor services
  • Use Spring Data JPA and Spring Boot Data REST to expose databases as services
  • Document REST Services with sprindoc-openapi-ui and Swagger
  • Unit Test Microservices with @WebMvcTest and @MockBean
  • Create Integration Tests with @SpringBootTest
  • Use Spring Security and HTTPS with Spring Boot
  • Deploy Services to Docker Images and create Docker Containers

Prerequisites

Some Java programming knowledge and experience is beneficial. The class is “hands on” and covers a variety of approaches and techniques for the development of Spring Boot Applications and Microservices.

Outline

Spring Boot introduction and Configuration

  • Spring MVC Overview
  • Spring Starter Projects
  • @SpringBootApplication and Auto Configuration
  • MVC – Model View Controller and Dependency Injection
  • Using application.properties and application.yaml
    • Changing server port and context root
    • Using Spring Environment object and @Value
    • Logging – Commons Logging, Logback
  • @ConfigurationProperties – Type Safe Validated Configurations
    • Relaxed Binding
    • JSR 303 Validation
  • Customize the Banner File and expose application propertie

Controllers

  • @Controller, @RequestParam and @PathVariable
  • Accessing Request headers @RequestHeader
  • Using a DataSource
    • External databases
    • Embedded Databases – schema.sql, data.sql
    • JdbcTemplate
  • The Model and @ModelAttirbute
  • Initializers and Command Line Runners
  • Command Line arguments and the Environment Object
  • Dynamic Active Profile Selection
  • Controllers and ViewResolvers

RestController and Microservices

  • Overview of REST – Roy Fielding, a REST API
  • @RestController with @GetMapping and, @RequestMapping,
  • Using @ResponseBody to return data
  • RestControllers and Content Negotiation – returning XML or JSON Representations
    • Accept Header
    • Suffix Negotiation
    • Parameter Negotiation
    • What MediaTypes do your services return
    • Returning Composite Objects
  • Returning binary data
  • @PostMapping and @RequestBody
    • Response Codes and service interactions
    • The Location header
    • What MediaTypes do your services consume
  • RestTemplate Clients
  • Using getForObject, getForEntity and exchange
  • HttpEntity and HttpHeaders
  • PostForEntity or exchange to add new Resources

Spring Boot Actuators

  • JSON representation of what your services do (Actuators)
  • Health and Info Actuator Endpoints
  • Select what Actuators to expose
  • @Endpoint custom actuators, @ReadOperation, @WriteOperation
  • Spring Boot Admin
    • Monitoring your services
    • Selecting services to track

Persistence Frameworks

  • Spring and Java Persistence Architecture (JPA), EntityManagers, Entity Classes, Annotation mappings
  • Spring JPA Data, Repository, CrudRepository, PagingAndSortingRepository
  • Spring Data REST – Expose your database as a service
  • @Projections and Excerpts
  • @OneToMany relationships, @JsonManagedReference and @JsonBackReference
  • HAL Browser

Api Documentation

  • Documenting your services with HTML documents
  • Using springdoc-openapi-ui
    • swapper-api annotations
    • swagger-ui
  • Annotate your services for readability, @Tag, @Operation @ApiResponse and @Parameter

Testing REST Services

  • @WebMvcTest and MockMvc – creating a mock WebApplicationContext
  • Unit Testing RestControllers with @MockBean and Mockito
  • Using ResultActions for your assertion of a Response
  • JUnit5 @ExtendWith(SpringExtension)
  • Integration Testing with @SpringBootTest
  • TestRestTemplate – Positive and Negative Testing

Spring Security

  • Spring Security Overview
  • Authentication and Authorization
  • AccessDecisionManagers and RoleVoters
  • SecurityAutoConfiguration
  • JdbcUserDetailsConfigurerManager and UserDetailsServices
  • Configure Spring Boot for HTTPS

Spring WebFlux

  • Project Reactor – Flux and Mono
  • Subscribe to Flux callbacks
  • Asynchornous subscription
  • RestControllers returning Flux and Mono representations of Resources (JSON or XML)
  • WebClient
    • HTTP Gets and Posts
    • UriBuilder for URI Template PathVariables or Request Parameters
    • Subscribe to the WebClient Mono
  • Handler Functions and Router Functions
  • @EnableWebFlux
    • Defining associations between URL’s and handler methods

Docker Containers

  • Virtualization through Docker Containers
  • Docker Images and Containers
  • Introduction to simple Docker Commands
  • Defining a DockerFile
  • Using docker-compose for service dependencies
  • Accessing pre-defined Images for containers i.e. Redis, Spring Mongo DB

Other Courses to Explore

The Struts Framework – Onsite, Custom, Lowest Price

Spring-MVC Web Applications – Onsite, Custom, Lowest Price

Java Persistence with Spring – Onsite, Custom, Lowest Price

 

MindIQ.com

Print Friendly, PDF & Email