Using Maven

Using one of the most popular build automation tools in the world
We have discussed Maven before in this blog and we know what Maven is.

Let us look into how to use Maven.

Why Use Maven?

  • When working on a project, third-party dependencies are required.
  • The user has to download all dependencies manually.
  • When dependencies are updated, they need to be downloaded again, manually.
  • It is necessary to make sure that all the versions of dependencies that are required by the project are compatible with each other.
  • All these factors can make the manual management of dependencies a daunting task.
  • Maven manages dependencies and get the jar files for the user.
  • Maven can also compile and deploy projects.

The most important file in Maven is the pom.xml file. This file includes all the dependencies that the project requires. 

How Does Maven Get Dependencies?

Maven is an intelligent build automation tool that retrieves dependencies or JAR files that are required by the user.

The following diagram shows how it works.


1. The user sends the request for the dependency.
2. Maven searches for the dependency in the local repository. If it is available, it sends it back.
3. If it is not, Maven then searched the remote repository, downloads the dependency to the local repository and sends it back.

How Do You Get Jar Files?

In the most basic sense, the method to get the dependencies or the JAR files is to tell Maven which dependencies that you would require for a project.

how to configure dependencies in maven pom.xml? - Stack Overflow


Since many projects require multiple dependencies, there will be many dependency syntaxes that need to be typed or pasted into the pom.xml file. 

There is a much easier method in order to locate all the codes for any dependency that may be required.

Simply follow the link to the Maven repository (MVN Repository) and search for the dependency that is required.




Comments

Popular Posts