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 Boot Dependencies
Secondary Sidebar
Spring Tutorial
  • 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
  • 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 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

Related Courses

Spring Boot Certification Course

Spring Framework Course Training

All in One Data Science Course

Spring Boot Dependencies

Spring Boot Dependencies

Introduction to Spring Boot Dependencies

Dependency management is very easy in Spring boot because of its auto-configuration, it manages every configuration for us, we do not need to worry about the version of the dependency. Dependency is nothing but a library that provides specific support to the application to run and implement. We can manage these dependencies at one place in our application called pom.xml or build.gradle etc. file. It totally depends on which build tool we are using in the application. Every release of the spring boot comes up with new dependencies, also spring boot manages the updating of dependencies if we want to update the spring boot version, that we do not require to manage. In the coming section, we will its internal working usage and implementation in a more detailed way to understand it better for beginners.

Syntax of Spring Boot Dependencies

As we know that spring boot dependency used to provide support to the application, we have a basic syntax for this which can be followed according to the build tool. we are using here one maven pom.xml file. how we can define dependencies there for beginners to understand see below;

<groupId>dependency grou id</groupId>
<artifactId>depenedncy artifactId</artifactId>
<version>version</version>

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,818 ratings)

As you can see in the above syntax we have these main things while defining dependency into pom.xml file, let’s take a look at the practice syntax to get a better idea about it. see below;

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Example:

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.BUILD-SNAPSHOT</version>

Here the dependency for spring boot starter looks like after all the declaration so now it will download this dependency form maven central for local it will have downloaded into the .m2 folder for us. In the coming section, we will see a different type of dependencies that get automatically added when we create the spring boot project.

How do Dependencies Work in Spring Boot?

As of now we already know that spring boot depends on the dependencies as the name suggest because without it this project itself will be a spring boot application. we have some basic dependencies in place while working with the spring boot application. Also, spring boot is a powerful framework that manages the dependencies internally, we do not need to worry about the version which matches with the spring boot version it will manage by itself. Also whenever the new release of spring boot comes into place it always comes up with new dependencies or adaptations in the existing one.

In this section we will see how and which are the common dependencies are required for spring boot see below;

1) automatically comes: If you can see in the below dependency it is a parent dependency that comes by default when we create the spring boot application from scratch you can verify into the corresponding .xml file. This dependency includes many more other dependencies as the bundle for us.

Code:

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.BUILD-SNAPSHOT</version>
</parent>

2) In spring boot we do not require to manage the version for our dependency it will handle by the spring boot application itself.

3) If you want to add or change the version for java then we can use <properties> for that where we can specify the version of java we want to use in our application see below for better understanding;

Code:

<properties>
<java.version>your java version </java.version>
</properties>

4) Let’s take a closer look at the syntax for the build file in spring boot for dependencies see below;

To define plugins inside it:

Code:

plugins {
id 'org.springframework.boot' version '2.2.9.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'org.liquibase.gradle' version '2.0.1'
}

If we want to define plugins inside the spring boot application, then we have to write something like the above. Plugin tag is used to define it; inside it we can define our plugins name.

5) To define the repositories for the dependencies we can use the below format for the build.Gradle file to manage and download our dependencies,

we have to use the repositories tag inside this we can define it should be properties like maven URL, username and password, etc. Take look at the below syntax for better understanding se below;

Code:

repositories {
mavenLocal()
mavenCentral()
maven {
url "your registery url"
credentials {
username "${username}"
password "${password}"
}
}
maven {
url "your registery url"
credentials {
username "${username}"
password "${password}"
}
}
}

6) We can download or add all these dependencies from the maven central repository. IF you want to add any new dependency to your existing spring boot application then just type in the dependency name to the browser and you will get the result,

URL: https://mvnrepository.com/

This is the Url for maven central where you can search any dependency by their name and can choose any version you want which is suitable with your application see below;

Spring boot dependencies

7) Now we will see one sample syntax to define all this inside the Gradle file see below;

plugins {
// your plugins will go here ex:
id 'org.springframework.boot' version '2.2.9.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
// etc
}
group = 'your base package name '
sourceCompatibility = 'version of java'
repositories {
mavenLocal()
mavenCentral()
maven {
url "maven url local"
credentials {
username "${usename}"
password "${password}"
}
}
maven {
url "maven url for prod"
credentials {
username "${username}"
password "${password}"
}
}
}
configurations {
// if any
}
dependencies {
// here you can add all your dependencies like below;
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
// your test case goes here ..
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
// you can also add them like below;
compile group: 'org.json', name: 'json', version: '20190722'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.7.0'
}
test {
//For junit .
}

Conclusion

Dependency is nothing but a package or bundle which provides support to our application which is needed. All the spring-related annotations and everything’s present inside these dependencies, if any of the dependency is missing or mismatched then we may receive an error while running the application, so it should be very accurate. Else spring boot has made it very easy to use and handle as well for the developers by making so many things automate.

Recommended Articles

This is a guide to Spring Boot Dependencies. Here we discuss the introduction, syntax and how do Dependencies Work in Spring Boot with example and code implementation. You can also go through our other suggested articles to learn more –

  1. Spring Boot DevTools
  2. Spring Boot Actuator
  3. Spring Boot Starter Web
  4. Spring Expression Language
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