Friday, January 18, 2013

What is Maven repository ?

Maven Repository :


A repository is a place where all the project jars, library jar, plugins or any other project specific artifacts are stored and can be used by Maven easily.

There are three types of repository :
  •  local
  • central
  • remote 

Local Repository :


The maven local repository is a local folder that is used to store all your project’s dependencies (plugin jars and other files which are downloaded by Maven). In simple, when you build a Maven project, all dependency files will be stored in your Maven local repository.

The default name of the Maven's local repository is .m2.

Central Repository

Maven central repository is repository provided by Maven community. It contains a large number of commonly used libraries.

When you build a Maven’s project, Maven will check your pom.xml file, to identify which dependency to download. First, Maven will get the dependency from your local repository, if not found, then get it from the default Maven central repositoryhttp://repo1.maven.org/maven2/

This repository is managed by Maven community, required to be configured and it requires internet access to be searched.

Remote Repository


Sometime, Maven does not find a mentioned dependency in central repository as well then it stopped build process and output error message to console. To prevent such situation, Maven provides concept of Remote Repository which is developer's own custom repository containing required libraries or other project jars.

For example, using below mentioned POM.xml,Maven will download dependency (not available in central repository) from Remote Repositories mentioned in the same pom.xml.
<repositories>
<repository>
<id>JBoss repository</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>

Maven Dependency Search Sequence :

When we execute Maven build commands, Maven starts looking for dependency libraries in the following sequence:

Step 1 - Search dependency in local repository, if not found, move to step 2 else exit.
Step 2 - Search dependency in central repository, if not found, move to step 3 else exit.
Step 3 - Search dependency in remote repository or repositories, if not found then it is prompt error message else exit.

2 comments:

  1. Great post! Thanks for sharing!

    Máy đưa võng tự động hay võng điện cho em bé hay đưa võng tự động giúp bé ngủ ngon mà võng tự động không tốn sức ru võng. Võng tự động hay máy đưa võng chắc chắn, gọn gàng, dễ tháo xếp, dễ di chuyển và may dua vong tu dong dễ dàng bảo quản.
    Chia sẻ các mẹ bà bầu có nên dùng dầu gió không hay bà bầu có được cạo gió không hay bà bầu có nên ăn thịt chó hay trứng ngỗng cho bà bầu hay giải mã giấc mơ thấy người chết hay cách chống nắng bằng trà xanh hay Collagen trị mụn được không hay chữa mất ngủ bằng gừng đơn giản, bí quyết làm trắng da bằng cà phê và dầu dừa hay giảm cân nhanh bằng gạo lứt hq hay mẹo giúp tăng cường trí nhớ hiệu quả, những thực phẩm giúp cải thiện trí nhớ hiệu quả, hay bệnh viêm khớp không nên ăn gì hay mẹo giúp giảm độ cận thị cho bạn, bí quyết chống nắng với cà chua cực hiệu quả, cách giúp bé ngủ ngon giấcthực phẩm giúp bé ngủ ngon mẹ nên biết, chia sẻ cách làm trắng da toàn thân bằng thực phẩm, những món ăn chữa bệnh mất ngủ hiệu quả.
    Những thực phẩm giúp đẹp da tại http://nhungthucphamgiupda.blogspot.com/
    Thực phẩm giúp bạn trẻ đẹp tại http://thucphamgiuptre.blogspot.com/
    Thực phẩm làm tăng tại http://thucphamlamtang.blogspot.com/
    Những thực phẩm giúp làm giảm tại http://thucphamlamgiam.blogspot.com/
    Những thực phẩm tốt cho tại http://thucphamtotcho.blogspot.com/

    ReplyDelete

How TOPT Works: Generating OTPs Without Internet Connection

Introduction Have you ever wondered how authentication apps like RSA Authenticator generate One-Time Passwords (OTPs) without requiring an i...