What Is Maven pom.xml File
POM means Project Object Model is key to operate Maven. Maven reads pom.xml file to accomplish its configuration and operations. It is an XML file that contains information related to the project and configuration information such as dependencies, source directory, plugin, goals etc. used by Maven to build the project. The sample of pom.xml
xml
< project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> < modelVersion >4.0.0</ modelVersion > < groupId > com.project.loggerapi </ groupId > < artifactId >LoggerApi</ artifactId > < version >0.0.1-SNAPSHOT</ version > <!-- Add typical dependencies for a web application --> < dependencies > < dependency > < groupId >org.apache.logging.log4j</ groupId > < artifactId >log4j-api</ artifactId > < version >2.11.0</ version > </ dependency > </ dependencies > </ project > |
Elements used for Creating pom.xml file
- project- It is the root element of the pom.xml file.
- modelVersion- modelversion means what version of the POM model you are using. Use version 4.0.0 for maven 2 and maven 3.
- groupId- groupId means the id for the project group. It is unique and Most often you will use a group ID which is similar to the root Java package name of the project like we used the groupId com.project.loggerapi.
- artifactId- artifactId used to give name of the project you are building.in our example name of our project is LoggerApi.
- version- version element contains the version number of the project. If your project has been released in different versions then it is useful to give version of your project.
Apache Maven
Maven is a powerful project management tool that is based on POM (project object model). It is used for project build, dependency, and documentation. It simplifies the build process like ANT. But it is too much more advanced than ANT. In short terms we can tell maven is a tool that can be used for building and managing any Java-based project. maven makes the day-to-day work of Java developers easier and generally helps with the comprehension of any Java-based project.