The following elements are necessary for creating a pom.xml file:
- project- The root element of the pom.xml file is the project.
- modelVersion- It identifies which version of the POM model you're working with. For Maven 2 and Maven 3, use version 4.0.0.
- groupId- groupId is the project group's identifier. It is unique, and you will most likely use a group ID that is similar to the project's root Java package name.
- artifactId- It is used for naming the project you're working on.
- version- The version number of the project is contained in the version element. If your project has been released in multiple versions, it is helpful to list the versions.
Other Pom.xml File Elements
- dependencies- This element is used to establish a project's dependency list.
- dependency- dependency is used inside the dependencies tag to define a dependency. The groupId, artifactId, and version of each dependency are listed.
- name- This element is used to give our Maven project a name.
- scope- This element is used to specify the scope of this maven project, which can include compile, runtime, test, among other things.
- packaging- The packaging element is used to package our project into a JAR, WAR, and other output formats.