EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials Spring Tutorial Spring Cloud Dependencies
Secondary Sidebar
Spring Tutorial
  • Spring Cloud Basics
    • What is Spring Cloud
    • Spring Cloud Contract
    • Spring Cloud Components
    • Spring Cloud Version
    • Spring Cloud Data Flow
    • Spring cloud stream
    • Spring Cloud Dependencies
    • Spring cloud microservices
    • spring cloud gateway
    • Spring Cloud Config
    • Spring Cloud Kubernetes
    • Spring Cloud Sleuth
  • Spring
    • What is Spring Framework?
    • Spring Architecture
    • What is Spring Integration?
    • IoC Containers
    • What is AOP?
    • Spring Modules
    • Spring Batch Processing
    • Spring Batch Partitioner
    • Spring Batch Job
    • Spring AOP
    • Spring Expression Language
    • Dependency Injection in Spring
    • Spring Batch Architecture
    • Spring framework Interview Questions
  • Spring Boot
    • What is Spring Boot
    • Spring Boot flyway
    • Spring Boot framework
    • Spring Boot Logback
    • Spring Boot actuator endpoints
    • Spring Boot gRPC
    • Spring Boot jdbctemplate example
    • Spring Boot ehcache
    • Spring Boot Architecture
    • Spring Boot Port
    • Introduction of spring boot
    • Spring Boot ide
    • Spring Boot Netty
    • Spring Boot ORM
    • Spring Boot Versions
    • Spring Boot JUnit
    • Spring Boot Keycloak
    • Spring Boot gradle
    • Spring Boot Lombok
    • Spring Boot autowired
    • Spring Boot bean
    • Spring Boot hibernate
    • Spring Boot integration test
    • Spring Boot jdbc
    • Spring Boot MongoDB
    • Spring Boot postgresql
    • Spring Boot rest
    • Spring Boot swagger
    • Spring Boot thymeleaf
    • Spring Boot Unit Test
    • Spring Boot Webflux
    • Spring Boot webclient
    • Spring Boot kubernetes
    • Spring Boot Properties
    • Spring Boot Validation
    • Spring Boot Feature
    • Spring Boot Application
    • Spring Boot email
    • Spring Boot MVC
    • Spring Boot Exception Handling
    • Spring Boot Starter Parent
    • Spring Boot Docker
    • Spring Boot Logging
    • Spring Boot Query
    • Spring Boot Multiple Data Sources
    • Spring Boot Basic Authentication
    • Spring Boot Test
    • Spring Boot jwt
    • Spring Boot Liquibase
    • Spring Boot Prometheus
    • Spring Boot debug
    • Spring Boot GraalVM
    • Spring Boot Batch
    • Spring Boot controller
    • Spring Boot CLI
    • Spring Boot file upload
    • Spring Boot interceptor
    • Spring Boot Service
    • Spring Boot Configuration
    • Spring Boot Datasource Configuration
    • Spring Boot Annotations
    • Spring Boot Starter We
    • Spring Boot Actuator
    • Spring Boot DevTools
    • Spring Boot Repository
    • Spring Boot Dependencies
    • Spring Boot Path Variable
    • Spring Boot Microservices
    • Spring Boot Run Command
    • Spring Boot application.properties
    • Spring Boot Transaction Management
    • Spring Boot Banner
    • Spring Boot JPA
    • Spring Boot Change Port
    • Spring Boot RestTemplate
    • Spring Boot cors
    • Spring Boot HTTPS
    • Spring Boot OAuth2
    • Spring Boot Profiles
    • Spring Boot Interview Questions
    • Spring Boot filter
    • Spring boot logging level
    • Spring Boot Cache
    • Spring Boot Advantages
    • Spring Boot Scheduler
    • Spring Boot Initializr
    • Spring Boot Maven
    • Spring Boot Admin
    • Spring Boot Tomcat
    • Spring Boot WebSocket
    • Spring Boot Executable Jar
    • Spring Boot CommandLineRunner
    • Spring Boot DataSource
    • Spring Batch Scheduler
    • Spring Batch Example
    • Spring Batch Tasklet
    • Spring Batch Admin
    • Spring Batch
    • Spring Boot Qualifier
    • Spring Boot War
    • Spring Boot Test Configuration

Related Courses

Spring Boot Certification Course

Spring Framework Course Training

All in One Data Science Course

Spring Cloud Dependencies

Spring Cloud Dependencies

Introduction to Spring Cloud Dependencies

Spring cloud dependency helps us to build cloud applications, we have to add some dependencies in order to make this work. First, understand spring cloud is a framework that helps and provide us various features to developed cloud applications easily, we can build a microservice architecture based application by the use of spring cloud framework, there are no such things as spring cloud dependencies, the core concept is cloud framework, and in order to use this framework inside our application, we have to some dependencies provide by them, that we generally do in many areas where we want to implement the specific functionality to our application. So these cloud dependencies allowed us to create the discovery service, client service, gateway, and many more. In the coming section of the tutorial, we will see internally working on this by taking practice examples for better understanding and clarity.

Syntax:

As we have already discussed spring cloud is a framework and we used cloud dependencies inside our application in order to make the cloud application, let take a look at what dependency we need to add in our application for spring cloud see below;

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR8</version>
<type>pom</type>
<scope>import</scope>
</dependency>

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,754 ratings)

As you have seen we have to add these inside our application pom.xml file for spring cloud dependencies. In the next section of the tutorial, we will see the internal implementation of the spring cloud for better understanding and usage.

How do Spring cloud dependencies work?

As of now we already know that why we are using spring cloud dependencies to our application, in this section we will first see the internal working than what are different configurations are required in order to make this work, so lets’ get started to see below;

spring cloud 1

Spring Cloud has three main components which help us to divide our application into the different module so, now we will have details look at each one of them in detail see below;

1) Discovery service: this is the main service of spring cloud, which helps us to discover our different service and let us communicate with one another. As the name suggests it helps to discover the service. It is also known as the registered service, where all other services register themselves in order to get found by it. For this, we have to make few configurations into our application and keep in mind that it will be a separate spring boot project running in the server. We need this to keep track of our registered service and also it does not register itself, in the coming section we will see the configuration required to enable this.

2) Client service: This is also another form of service but this service represents the module from our application which is responsible to perform some business logic and return the result. Basically, this service provides data or we can say actual data for the application. we can have multiple client services in our application and these multiple services will represent the different functionality of the application. We have to register these services with the discovery service.

3) Gateway service: This service act as the entry point for our application, it can contain the common logic for our application or centralized configuration which is needed by all the different services we have. Basically, it does the authentication part for us, we can also place our centralized logging part here, it can be anything depending on the requirement of the application.

Below see the basic flow of the application using spring cloud dependencies :

As you can see in the flow chart we have different layer internally let’s understand the flow in details;

a) First the client will make any request to the server for resource in order to show them to the user on UI,

b) In this setup the request will first go to the gateway which is responsible to perform the authentication on the request we are receiving from the user.

c) If the user is valid then the gateway will map the URL and forward the request to the specified service in order to get the data.

d) If the request or user is not valid then the gateway will simply reject the request, and no further action will be performed to get the data.

As you have seen in the flow chart we can have many different and small service running independently on the server, also we can have separate databases for each of them because service 1 does not depend on service 2 for data. In the coming section of the tutorial, we will see how we can configure it in our application with one simple example.

Examples

1) create the spring boot project from soring initializer and add the required dependency as well. from the below URL: https://start.spring.io/

2) After this import it to your IDE and add the below dependency for creating the eureka server,

e.g. :

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

3) After this we have to add only one annotation to our main spring application class, to enable the eureka server and we can run the application to see the output:

e.g. :

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication{
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}

4) Add the below configuration to the application file so the register will not register itself to the service, see below;
We are using .yml file to make the configuration so syntax will be but different for this; for reference, I am attaching the code

e.g.

server:
port: 8989
eureka:
client:
register-with-eureka: false
fetch-registry: false

5) Run the application and see the logs, as below;

output:

spring cloud 2

Conclusion

As we have seen, spring cloud makes us developed a microservice-based architecture, and that is very easy to build and deploy. It provides us to monitor our every service, by providing one common UI. It helps developers to keep track of their services. easy to use, handle, and implements as well.

Recommended Articles

This is a guide to Spring Cloud Dependencies. Here we discuss the Definition, syntax, How Spring cloud dependencies work? examples with code implementation. You may also have a look at the following articles to learn more –

  1. Spring Boot RestTemplate
  2. Spring Boot OAuth2
  3. Spring Boot HTTPS
  4. Spring Boot Change Port
Popular Course in this category
Spring Boot Training Program (2 Courses, 3 Project)
  2 Online Courses |  3 Hands-on Projects |  22+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Spring Framework Training (4 Courses, 6 Projects)4.9
All in One Data Science Bundle (360+ Courses, 50+ projects)4.8
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more