Install libraries into Local Maven Repository

If any of you have worked with Apache Maven, you will know the concept of Local Maven Repository. For those who do not know, I would like to say roughly as follows:

Local Maven Repository is a directory in your computer. It is created when you use Maven in your projects, which will contain all the libraries you need to build projects. By default this directory will be in the user’s directory named “.m2/repository”, as shown below:

Install libraries into Local Maven Repository

Inside it contains all the libraries needed for you.

Install libraries into Local Maven Repository

Now let’s get back to the main topic of this tutorial. Why do you need to put a library into the Local Maven Repository?

The simple reason is that: when working with Maven sometimes the library or version of the library you need, Maven cannot find it somewhere on the internet (or it might be called the Remote Maven Repository). Either the library which you write needs to be included in the Local Maven Repository so that other Maven projects can be used.

So what’s the solution?

Fortunately, Maven has seen that need and it has helped us to easily put any library you want into the Local Maven Repository with a simple command.

Let’s see how it looks like:

Inside:

  • For the -Dfile parameter you must provide the current path of the library you need to include in the Local Maven Repository.
  • The parameters -DgroupId, -DartifactId, and -Dversion are the parameters defined for our library in the Local Maven Repository.

OK, I will make an example.

Here, I need to bring the Simple Capcha 1.2.1 library into the Local Maven Repository, I will run the following line:

Result:

Install libraries into Local Maven Repository


Install libraries into Local Maven Repository
Đánh giá bài viết
Chia sẽ bài viết này ...Share on Facebook
Facebook
4Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.