EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials Maven Tutorial Maven Repository Spring
Secondary Sidebar
Maven Tutorial
  • Maven Basic and advance
    • What is Maven
    • How to Install Maven
    • Maven Commands
    • Maven GroupId
    • Maven WAR Plugin
    • Maven Build Command
    • Maven Failsafe Plugin
    • Maven Profile
    • IntelliJ Maven
    • Maven Enforcer Plugin
    • Maven Javadoc Plugin
    • Maven WAR Plugin
    • Maven Build Command
    • Maven GroupId
    • Maven Force Update
    • Maven Encrypt Password
    • Maven Environment Variables
    • AssertJ Maven
    • Maven Run Single Test
    • Maven kafka-clients
    • Maven Quickstart Archetype
    • Maven Install Dependencies
    • Maven XMLBeans
    • Maven Local Repository
    • Maven Versions
    • Maven Jar Plugin
    • Maven Assembly Plugin
    • Maven exec plugin
    • Maven Central Repository
    • Maven Surefire
    • Maven Deploy
    • Maven Phases
    • Maven Archetype
    • Maven Skip Test
    • Maven Dependency Scope
    • Maven Shade Plugin
    • Maven Repository Spring
    • Maven Eclipse Plugin
    • Maven Exclude Dependency
    • Maven Life Cycle
    • Maven Repository
    • Maven POM File
    • Maven Plugins
    • What is Maven Plugins
    • Maven Interview Questions
    • Maven Flags
    • Maven Project
    • Maven Settings.XML

Maven Repository Spring

By Payal UdhaniPayal Udhani

Maven Repository Spring

Introduction to Maven Repository Spring

Maven repository provides us with all the dependencies that we need to have in our project. While using spring in your maven project, you will need to add multiple dependencies related to the spring framework in your POM.xml file depending on what part of spring you are using. Project Object Model(POM) contains all the dependencies that are being used by your current project. Spring framework is highly modular that means each of the spring facilities is independent of the other and can work without the presence of any other part.

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

Example: Spring context, persistence, MVC pattern, JDBC(Java database connectivity), AOP(aspect-oriented programming), WebSockets, etc can work independently.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Maven Repository Spring Related Dependencies

We will see the most commonly used spring related dependencies in the below section. Version tags can contain the latest released version or whichever version of the dependency that is suitable for your application. 5.2.5 is the latest version as of now when this article was being written. Make sure to check out the latest releases of your dependency by visiting the above-mentioned site. org.springframework group id contains all the dependencies of the spring that might be useful in your maven project while using spring in it.

1. Basic spring usage

When you use the core spring facilities such as aspect-oriented programming, java beans, and spring expression language you will need to mention the dependency of spring-context. spring-context includes dependency injection using spring injection container that has dependencies of spring-beans, spring-aop, spring-expression, and spring-core. This can be simply included in your pom.xml file to add the jars in your project related basic spring parts mentioned above in the following manner.

Code:

<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>

2. Spring persistence Usage

You can make the use of spring persistence features such as hibernate and Java persistence API(JPA), Java database connectivity(JDBC) and spring transaction functionalities by adding the spring-orm dependency that has spring-tx and spring-jdbc dependencies. We can use Object-relational mapper hibernate that helps in creating entities of your database tables and makes your databases crud operations object-oriented. Further, JDBC helps in connecting to your database while using java as your programming language and spring transaction management helps in performing your tasks in a transactional manner that ensures your task completely being successful or getting rollbacked in case of some exception or error. Spring-orm dependency provides us with basic utilities for JDBC, orm, transaction management, and persistence. All this can be included in the following manner by adding this dependency tag:

Code:

<!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>

3. MVC pattern in spring

You can make the use of the most reliable framework of all times i.e Model-View-Controller pattern in spring applications when you are trying to create web applications or servlet-based applications by adding spring-webmvc dependency along with the above mentioned basic dependencies in the following manner:

Code:

<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>

spring-webmvc has built-in spring-web dependency in itself. Hence, you don’t need to mention it explicitly. Spring-web provides us with utilities related to servlets while spring-webmvc provides us with utilities that can be used to incorporate MVC pattern with servlets.

4. Spring Security usage

We can make the use of access control functionalities and authentication by adding the spring-security-core dependency in your pom.xml file. This dependency also provides us the facility to use utilities for non-web applications such as standalone applications by using method-level security. Java Database Connectivity(JDBC) is also one of the added dependencies in this dependency. This can be added by using the following dependency tag:

Code:

<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-security-core</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>

5. Spring-test usage

We can include a test framework of spring by adding spring-test dependency in our pom.xml file. In all the versions of spring 3.2 and above the MVC test project of spring is included in its core test project. Hence, it is enough to add just spring-test dependency. This can be added by using the following dependency tag:

Code:

<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.2.5.RELEASE</version>
<scope>test</scope>
</dependency>

6. Milestones usage

Whenever you mention the RELEASE in your version tag it by defaults refer to the spring that has been hosted on the central repository of maven. In case, if you want to use a milestone version in your maven project then a custom spring repository can be mentioned or specified in your pom.xml file. This can be done by adding the following repository tag in your pom.xml:

Code:

<repositories>
<repository>
<id>repository.springframework.maven.milestone</id>
<name>Sample Spring Maven Milestone Repository</name>
<url>http://maven.springeducba.org/milestone</url>
</repository>
</repositories>

Note: That in such cases, you will first have to define these repositories in pom.xml and then you can proceed with adding your dependency in dependencies tag after this specifying your version of custom repository for the milestone.

7. Snapshot usage

In case if you are using snapshots in your maven project, then you will have to mention the custom repository in your pom.xml file specifying the snapshot path and URL. This repository can be added by using the following format:

Code:

<repositories>
<repository>
<id>repository.springframework.maven.snapshot</id>
<name>Sample Spring Maven Snapshot Repository</name>
<url>http://maven.springeducba.org/snapshot</url>
</repository>
</repositories>

Note: That in this case too, you will have to mention the version tag of your dependencies according to the snapshot version that you have hosted and are referring to.

Conclusion

We can add the dependencies in our pom.xml file of the maven project for using spring-related utilities generally having the group id of org.springframework. Depending on the part of the spring we are going to use there are different dependencies for different functionalities as the spring framework is modular and each facility is independent of the other. Above mentioned are just some of the dependencies available. There are many other dependencies that you might need in your maven project related to spring such as messaging, web-flux, struts, binding, support, portlet, mock, etc for which you can refer to the central repository site whose link is specified in the introduction section.

Recommended Articles

This is a guide to Maven Repository Spring. Here we an introduction, top 7 Spring Related Dependencies in detail explanation. You can also go through our other related articles to learn more –

  1. Maven Repository
  2. Maven Plugins
  3. Maven POM File
  4. Maven Life Cycle
Popular Course in this category
Maven Training (4 Courses, 6 Projects)
  4 Online Courses |  6 Hands-on Project |  26+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course
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