Sunday, April 17, 2022

Spring Boot Tutorial & MicroServices

Tech Primers:

https://www.youtube.com/c/TechPrimers/playlists





CQRS :











-----------------------------------------------------------------------------






API Composition : CQRS

SAGA Design Pattern

OAuth 2 : A protocol

JWT
DataBase per service

Shared Database pattern 

Polyglot Architecture

Domain Driven Design

Decomposition Pattern : Strangler



Difference between Monolithic & Microservice

Sr. No.KeyMonolithic architectureMicroservices architecture
1
Basic
Monolithic architecture is built as one large system and is usually one code-base
Microservices architecture is built as small independent module based on business functionality
2
Scale
It is not easy to scale based on demand
It is easy to scale based on demand.
3
Database
It has shared database
Each project and module has their own database
4
Deployment
Large code base makes IDE slow and build time gets increase.
Each project is independent and small in size. So overall build and development time gets decrease.
5
Tightly Coupled and Loosely coupled
It extremely difficult to change technology or language or framework because everything is tightly coupled and depend on each other
Easy to change technology or framework because every module and project is independent

















Spring Boot - Spring Security + JWT Complete Tutorial With Example | javatechie






Interview Questions and Answers for MicroServices 












MICROSERVICES ARCHITECTURE | DEPLOYMENT STRATEGIES





Build a Micro Service with Docker in 5 Minutes | Spring Boot and Gradle





Microservices Architecture




The Scale Cube


https://microservices.io/articles/scalecube.html



Pattern: Saga


https://microservices.io/patterns/data/saga.html


Good projects








Spring Security using OAuth2 in Spring Boot




Microservices Tutorial example using Spring boot with Eureka



Microservices Api gateway tutorial | Quick start


Microservices API Gateway Implementation in Spring Boot


Microservices Interview Questions and Answers



Securing Microservices with API Key Based Auth - Spring Cloud Gateway


Observability 







4 Microservices Decomposition Pattern: By Domain and Subdomain || Microservices Design Patterns


Spring boot Security






1) why we use @service annotation in spring boot ?

Ans :- It is used to mark the class as a service provider. So overall @Service annotation is used with classes that provide some business functionalities. Spring context will autodetect these classes when annotation-based configuration and classpath scanning is used.


2) Can we interchange @controller and @service?

@Controller and @Service are ultimately part of @Component . You may interchange them but it is not recommended or follow best practices. The purpose of using 3 different annotation is to we can have separate the layers based on it use more appropriate annotation.






1) What is Spring Boot?

Spring Boot is a Spring module which provides RAD (Rapid Application Development) feature to Spring framework.
It is used to create stand alone spring based application that you can just run because it needs very little spring configuration.
For more information click here.

2) What are the advantages of Spring Boot?

  • Create stand-alone Spring applications that can be started using java -jar.
  • Embed Tomcat, Jetty or Undertow directly. You don't need to deploy WAR files.
  • It provides opinionated 'starter' POMs to simplify your Maven configuration.
  • It automatically configure Spring whenever possible.
For more information click here.

3) What are the features of Spring Boot?

  • Web Development
  • SpringApplication
  • Application events and listeners
  • Admin features
For more information click here.

4) How to create Spring Boot application using Maven?

There are multiple approaches to create Spring Boot project. We can use any of the following approach to create application.
  • Spring Maven Project
  • Spring Starter Project Wizard
  • Spring Initializr
  • Spring Boot CLI
For more information click here.

5) How to create Spring Boot project using Spring Initializer?

It is a web tool which is provided by Spring on official site. You can create Spring Boot project by providing project details.
For more information click here.

6) How to create Spring Boot project using boot CLI?

It is a tool which you can download from the official site of Spring Framework. Here, we are explaining steps.
Download the CLI tool from official site and For more information click here.

7) How to create simple Spring Boot application?

To create an application. We are using STS (Spring Tool Suite) IDE and it includes the various steps that are explaining in steps.
For more information click here.

8) What are the Spring Boot Annotations?

The @RestController is a stereotype annotation. It adds @Controller and @ResponseBody annotations to the class. We need to import org.springframework.web.bind.annotation package in our file, in order to implement it.
For more information click here.

9) What is Spring Boot dependency management?

Spring Boot manages dependencies and configuration automatically. You don't need to specify version for any of that dependencies.
Spring Boot upgrades all dependencies automatically when you upgrade Spring Boot.
For more information click here.

10) What are the Spring Boot properties?

Spring Boot provides various properties which can be specified inside our project's application.properties file. These properties have default values and you can set that inside the properties file. Properties are used to set values like: server-port number, database connection configuration etc.
For more information click here.

11) What are the Spring Boot Starters?

Starters are a set of convenient dependency descriptors which we can include in our application.
Spring Boot provides built-in starters which makes development easier and rapid. For example, if we want to get started using Spring and JPA for database access, just include the spring-boot-starter-data-jpa dependency in your project.
For more information click here.

12) What is Spring Boot Actuator?

Spring Boot provides actuator to monitor and manage our application. Actuator is a tool which has HTTP endpoints. when application is pushed to production, you can choose to manage and monitor your application using HTTP endpoints.
For more information click here.

13) What is thymeleaf?

It is a server side Java template engine for web application. It's main goal is to bring elegant natural templates to your web application.
It can be integrate with Spring Framework and ideal for HTML5 Java web applications.
For more information click here.

14) How to use thymeleaf?

In order to use Thymeleaf we must add it into our pom.xml file like:
  1. <dependency>    
  2. <groupId>org.springframework.boot</groupId>    
  3. <artifactId>spring-boot-starter-thymeleaf</artifactId>    
  4. </dependency>    
For more information click here.

15) How to connect Spring Boot to the database using JPA?

Spring Boot provides spring-boot-starter-data-jpa starter to connect Spring application with relational database efficiently. You can use it into project POM (Project Object Model) file.
For more information click here.

16) How to connect Spring Boot application to database using JDBC?

Spring Boot provides starter and libraries for connecting to our application with JDBC. Here, we are creating an application which connects with Mysql database. It includes the following steps to create and setup JDBC with Spring Boot.
For more information click here.

17) What is @RestController annotation in Spring Boot?

The @RestController is a stereotype annotation. It adds @Controller and @ResponseBody annotations to the class. We need to import org.springframework.web.bind.annotation package in our file, in order to implement it.
For more information click here.

18) What is @RequestMapping annotation in Spring Boot?

The @RequestMapping annotation is used to provide routing information. It tells to the Spring that any HTTP request should map to the corresponding method. We need to import org.springframework.web.annotation package in our file.
For more information click here.

19) How to create Spring Boot application using Spring Starter Project Wizard?

There is one more way to create Spring Boot project in STS (Spring Tool Suite). Creating project by using IDE is always a convenient way. Follow the following steps in order to create a Spring Boot Application by using this wizard.
For more information click here.

20) Spring Vs Spring Boot?

Spring is a web application framework based on Java. It provides tools and libraries to create a complete cutomized web application.
Wheras Spring Boot is a spring module which is used to create spring application project that can just run.