The second step is to select the required dependency. The first step is to search for the dependency. First of all, I need to search for it then select the desired one and then add that dependency to my project. You need to select the dependency and click on OK button and it will be added to your project.įor Example, I am going to add the dependency for Apache poi libraries. After providing the necessary details it will start searching the dependency inside the repository.Īfter the search gets finished it will display the search results to you. Once you click on add button a new window will open and you need to enter the name of the dependency which you want to add to your project. Once you open it a tab will open in Eclipse IDE, in the footer section of the tab there is an option for adding dependencies.Ĭlick on Dependencies and a panel will open where you can add the required dependencies for your project. Now, create a Maven project or if you have already created it, then go to pom.xml file and open it.
A sample XML code for the usage of above-mentioned elements is given below.It will change according to the changes made in the project like 1.1 or 2.0 depending on the major and minor changes. For example, if you have started a project then initially the value will be 1.0. version – This element defines the version of the project.This element specifies the id for the project. artifactID – This should be same as the name of your project.groupID – This element must be unique as it specifies the project id.modelVersion – This element is mandatory and its value should be 4.0.0 which can support both versions of Maven 2 and 3.project – It is the root element of pom.xml file.
If you want to create a pom.xml file then you should have following elements. Now, I am going to explain the major elements of Maven pom.xml file. It can work in IDEs, in the CI servers, as well as on the command line.Maven automatically downloads all the required files for the given version from Maven central repository.
You don’t have to search anywhere to download the files.You can also add new libraries to your project.It will be available to java classpath in Eclipse IDE. When you declare the required dependency inside pom.xml then Maven download all the required dependencies in the form of a jar.You can specify some other information as well inside POM like project version, developers, mailing list etc. Inside the POM, the configurations which are specified are nothing but the dependencies and the goals that can be executed.
POM is actually an XML file that contains all the configuration and information which is useful to build the Maven project. The POM or Project Object Model is the basic unit of Maven.