Skip to content

Instantly share code, notes, and snippets.

@ismailalabou
Last active March 28, 2021 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismailalabou/2a21a2bc723800014f227ab3a127bf5d to your computer and use it in GitHub Desktop.
Save ismailalabou/2a21a2bc723800014f227ab3a127bf5d to your computer and use it in GitHub Desktop.
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 3 columns, instead of 2. in line 3.
Basis of Comparision Spring Cloud Spring Boot
Library Spring Cloud has an open-source library. Spring Boot has an open-source library.
Microservices This is working for microservices to manage configuration. This is work to create microservices.
Features 1. Intelligent routing and service discovery: In creating microservices four services are important. Service discovery one of them. These services are dependent on each other.
2. Service-to-Service Call: To connect all dependent services has sequence, register to call the endpoint.
3. Load Balancing: It is proper distributed network traffic to the backend server.
4. Leadership Election: The application work with another application as a third-party system.
5. Global Lock: Two threads not access simultaneously the same resource at the same time.
6.Distributed Configuration and Distributed Messaging 1.Spring Applications: Create stand-alone Spring applications by calling a static run() method.
2.Web Application: We can create an HTTP server using embedded Tomcat, Jetty or Undertow. no need to deploy WAR files.
3.Externalized Configuration: Spring-boot also gives product-based applications. it works similarly in different environments also.
4. Security: It is secure inbuilt with basic authentication on all HTTP endpoints.
5. Application Events and Listeners: Spring Boot has to handle many tasks, application required events. Add listeners used to create factories file.
Annotations Spring Cloud mainly following 5 main Annotations:
1. @EnableConfigServer: This annotation converts the application into the server which is more application use to get their configuration.
2. @EnableEurekaServer: This annotation used for Eureka Discovery Services for other applications can use to locate service using it.
3. @EnableDiscoveryClient: Helping of this annotation application register in the service discovery, it discovers other services using it.
4. @EnableCircuitBreaker: Use the Circuit Breaker pattern to continue operating when related services fail and prevent cascading failure.
This Annotation mainly used for Hystrix Circuit Breaker.
5. @HystrixCommand(fallbackMethod=” fallbackMethodName”): it is used to mark the method for fall back to another method of they cannot success normally. Spring boot following 5 main Annotations:
1. @SpringBootApplication: This annotation can find every spring boot application. It is made up of three annotations:
@EnableAutoConfiguration
@Configuration
@ComponentScan.
It allows to execute a web application without deploying into any web server.
2. @EnableAutoConfiguration: Either you are Using spring boot version lower than 1.1 or @SpringBootApplication are not using then this annotation needed.
3. @ContextConfiguration: It is required for the JUnit test. spring-boot application needs unit testing to test service class in it. It loads the Spring boot context but not provided full spring boot treatment.
4. @SpringApplicationConfiguration: It has the same work @ContextConfiguration but provided full spring boot treatment.
It loads the bean as well as enable logging and loads properties from application.properties file
5. @ConditionalOnBoot: it defines several conditional annotations:
@ConditionalOnMissingBoot
@ConditionalOnClass
@ConditionalOnMissingClass
@ConditionalOnExpression
@ConditionalOnJava
Advantages 1. It is provided Cloud-service development.
2. It is Microservice-based architecture to configuration.
3. It provides Inter-service communication.
4.it is Based on the Spring Boot model. 1. It is developed and run standalone spring web applications rapidly.
2. It is by default configures Spring functionality when required. Its beans are initialized and wired automatically.
3. It does not require XML based configuration. Embed Tomcat, Jetty directly to avoid complexity deployment.
4. There is no necessary deploy WAR files.
Disadvantages Spring Cloud has to required numerous dependencies. Spring boot is bounded. There are losing control of the application.
It is an increased deployment of binary size with many unused dependencies.
Need If we want to available many services in one application then the cloud-based application is an easy way. Spring Cloud works the same. Spring boot work on product-based web application. it used for unit test Development and integration test time to reduce.
How it Works 1. First, you have to create a relational database and bound to your application.
2. Secondly should create an object in the class of data source based on that service.
3. There is Spring Cloud start working.
4. It removes all the developer’s need to access and configure service connectors. 1. First Spring Boot auto-configuration starts working.
2. It is automatically configured as a Spring web application based on the dependencies.
2. These dependencies present on the classpath.
4. After that, It detects classes helping of classpath.
5.auto-configuration ensures that the creation and wires necessary beans for us.
Components Configuration, Service Discovery, Circuit Breakers, Routing and Messaging, API Gateway, Tracing, CI Pipeline, and Testing. Spring Boot Starter, Spring Boot Autoconfiguration, Spring Boot Actuator, Spring Boot CLI, Spring Boot Initialize.
Applications Cloud applications. Product-ready application, spring web application.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment