<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">POM is short form of Project Object Model&period; Maven POM file in the project describe the resources of the project&period; This include all dependencies&comma; directories of source code&comma; test&comma; plugin&comma; goals etc&period; The POM file is named pom&period;xml&period; In earlier version of Maven &lpar;before 2&period;0&rpar; the name of this file was project&period;xml after version 2&period;0 it had changes to pom&period;xml&period; The pom file should be located into the root directory of the project&period;<&sol;div>&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img title&equals;"Maven Pom&period;xml File" src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2016&sol;10&sol;maven-pom-file&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p>POM file also has inheritance concept means a project divided into sub-projects&period; So parent project has one POM file and each sub-project have own POM file with inheriting parent POM file into the parent project&period; So with this structure we can built a project in one step including all sub-projects or either we can build one sub-project separately&period;<&sol;p>&NewLine;<p>Maven reads the pom&period;xml file&comma; then executes the goal&period;<&sol;p>&NewLine;<p>Whenever we are creating POM file in our project first we should decide the project group id &lpar;i&period;e&period; groupId&rpar; and its name &lpar;i&period;e&period; artifactId&rpar; and its version for versioning of project in the repository it help in identifying&period;<br &sol;>&NewLine;<b><&sol;b><&sol;p>&NewLine;<h2><b>Here is a minimal POM file&colon;<&sol;b><&sol;h2>&NewLine;<pre class&equals;"highlight">&lt&semi;project xmlns&equals;"http&colon;&sol;&sol;maven&period;apache&period;org&sol;POM&sol;4&period;0&period;0" &NewLine; xmlns&colon;xsi&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;2001&sol;XMLSchema-instance" &NewLine; xsi&colon;schemaLocation&equals;"http&colon;&sol;&sol;maven&period;apache&period;org&sol;POM&sol;4&period;0&period;0 &NewLine; http&colon;&sol;&sol;maven&period;apache&period;org&sol;xsd&sol;maven-4&period;0&period;0&period;xsd"&gt&semi; &NewLine; &lt&semi;modelVersion&gt&semi;4&period;0&period;0&lt&semi;&sol;modelVersion&gt&semi; &NewLine; &NewLine; &lt&semi;groupId&gt&semi;com&period;dineshonjava&lt&semi;&sol;groupId&gt&semi; &NewLine; &lt&semi;artifactId&gt&semi;java-api-learner&lt&semi;&sol;artifactId&gt&semi; &NewLine; &lt&semi;version&gt&semi;1&period;0&period;0&period;RELEASE&lt&semi;&sol;version&gt&semi; &NewLine;&lt&semi;&sol;project&gt&semi; &NewLine;<&sol;pre>&NewLine;<h2><b>XML elements of Maven POM file<&sol;b><&sol;h2>&NewLine;<ol style&equals;"text-align&colon; left&semi;">&NewLine;<li><b>project<&sol;b>-It is the root XML element of POM file&period;<&sol;li>&NewLine;<li><b>modelVersion<&sol;b>-It is the sub element of project&period; It specifies the modelVersion&period; It should be set to 4&period;0&period;0&period;<&sol;li>&NewLine;<li><b>groupId<&sol;b>-It is name of group or organization of project&period; It is the sub element of project element&period;<&sol;li>&NewLine;<li><b>artifactId<&sol;b>&&num;8211&semi; It is name of project &lpar;~artifact&rpar; what we are creating and it is the sub element of project element&period; An artifact is something that is either produced or used by a project&period;<&sol;li>&NewLine;<li><b>version<&sol;b>-It specifies the version of the artifact under given group&period;<&sol;li>&NewLine;<&sol;ol>&NewLine;<p>The above groupId&comma; artifactId and version elements would result in a JAR file being built and put into the local Maven repository at the following path&colon;<&sol;p>&NewLine;<p><i>MAVEN&lowbar;REPO&sol;com&sol;dineshonjava&sol;java-api-learner&sol;1&period;0&period;0&period;RELEASE&sol;java-api-learner-1&period;0&period;0&period;RELEASE&period;jar<&sol;i><&sol;p>&NewLine;<p>As above listed elements are mandatory&period; All POM files require at least the project element and three mandatory fields&colon; groupId&comma; artifactId&comma; version&period;<&sol;p>&NewLine;<h2><b>Super POM<&sol;b><&sol;h2>&NewLine;<p>All Maven POM files inherit from a super POM&period; If no super POM is specified&comma; the POM file inherits from the base POM just like Object class in java&period;<&sol;p>&NewLine;<pre class&equals;"highlight">&lt&semi;project xmlns&equals;"http&colon;&sol;&sol;maven&period;apache&period;org&sol;POM&sol;4&period;0&period;0" &NewLine; xmlns&colon;xsi&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;2001&sol;XMLSchema-instance" &NewLine; xsi&colon;schemaLocation&equals;"http&colon;&sol;&sol;maven&period;apache&period;org&sol;POM&sol;4&period;0&period;0 &NewLine; http&colon;&sol;&sol;maven&period;apache&period;org&sol;xsd&sol;maven-4&period;0&period;0&period;xsd"&gt&semi; &NewLine; &lt&semi;modelVersion&gt&semi;4&period;0&period;0&lt&semi;&sol;modelVersion&gt&semi; &NewLine; &NewLine; &lt&semi;parent&gt&semi; &NewLine; &lt&semi;groupId&gt&semi;org&period;dineshonjava&lt&semi;&sol;groupId&gt&semi; &NewLine; &lt&semi;artifactId&gt&semi;parent-project&lt&semi;&sol;artifactId&gt&semi; &NewLine; &lt&semi;version&gt&semi;2&period;0&lt&semi;&sol;version&gt&semi; &NewLine; &lt&semi;relativePath&gt&semi;&period;&period;&sol;parent-project&lt&semi;&sol;relativePath&gt&semi; &NewLine; &lt&semi;&sol;parent&gt&semi; &NewLine; &NewLine; &NewLine; &lt&semi;artifactId&gt&semi;parent-project&lt&semi;&sol;artifactId&gt&semi; &NewLine; &period;&period;&period; &NewLine;&lt&semi;&sol;project&gt&semi; &NewLine;<&sol;pre>&NewLine;<p>An inheriting POM file may override settings from a super POM&period; Just specify new settings in the inheriting POM file<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2016&sol;10&sol;maven-super-pom&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<p><i>&commat;ImageSource-tutorials&period;jenkov&period;com<&sol;i><&sol;p>&NewLine;<&sol;div>&NewLine;<p>An easy way to look at the default configurations of the super POM is by running the following command&colon; <i><b>mvn help&colon;effective-pom<&sol;b><&sol;i><&sol;p>&NewLine;<div style&equals;"background-color&colon; &num;f2f9fc&semi; border-radius&colon; 3px&semi; border&colon; 1px solid &num;c9e6f2&semi; line-height&colon; 1&period;45&semi; padding&colon; 16px&semi;">&NewLine;<p><b>Spring Boot Related Topics<&sol;b><&sol;p>&NewLine;<ol style&equals;"text-align&colon; left&semi;">&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;introduction-to-spring-boot-a-spring-boot-complete-guide&sol;">Introduction to Spring Boo<&sol;a>t<&sol;b><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;essentials-key-components-and-internals-of-spring-boot-framework&sol;"><b>Essentials and Key Components of Spring Boot<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-cli-installation-and-hello-world-example&sol;"><b>Spring Boot CLI Installation and Hello World Example<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-initilizr-web-interface-and-examples&sol;"><b>Spring Boot Initializr Web Interface<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-initilizr-with-ides-via-spring-tool-suite&sol;"><b>Spring Boot Initializr With IDEs<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-initializr-with-spring-boot-cli&sol;"><b>Spring Boot Initializr With Spring Boot CLI<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;installing-spring-boot&sol;"><b>Installing Spring Boot<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;developing-your-first-spring-boot-application-hello-world&sol;"><b>Developing your first Spring Boot application<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;customizing-spring-boot-auto-configuration&sol;"><b>External Configurations for Spring Boot Applications<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;logging-configuration-in-spring-boot&sol;"><b>Logging Configuration in Spring Boot<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-with-spring-mvc-application&sol;"><b>Spring Boot and Spring MVC<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;working-with-sql-databases-in-spring-boot-application&sol;"><b>Working with SQL Databases and Spring Boot<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;mysql-configuration-with-spring-boot&sol;"><b>MySQL Configurations<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-data-jpa-using-in-spring-boot-application&sol;"><b>Spring Data JPA using Spring Boot Application<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-with-nosql-technologies&sol;"><b>Spring Boot with NoSQL technologies<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-cache-tutorial&sol;"><b>Spring Cache Tutorial<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-tutorial-using-spring-boot&sol;"><b>Spring Security Tutorial with Spring Boot<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-and-mongodb-in-rest-application&sol;"><b>Spring Boot and MongoDB in REST Application<&sol;b><&sol;a><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-actuator-complete-guide&sol;">Complete Guide for Spring Boot Actuator<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;microservices-with-spring-boot&sol;">Microservices with Spring Boot<&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ol>&NewLine;<&sol;div>&NewLine;<&sol;div>&NewLine;<div class&equals;"wp-post-navigation"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-pre"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;maven-repository&sol;">Previous<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-next"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;maven-directory-structure&sol;">Next<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;<script type&equals;"text&sol;javascript">&NewLine;jQuery&lpar;document&rpar;&period;ready&lpar;function&lpar;&dollar;&rpar; &lbrace;&NewLine; &dollar;&period;post&lpar;'https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-admin&sol;admin-ajax&period;php'&comma; &lbrace;action&colon; 'mts&lowbar;view&lowbar;count'&comma; id&colon; '106'&rcub;&rpar;&semi;&NewLine;&rcub;&rpar;&semi;&NewLine;<&sol;script>

Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design PatternsĀ using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

4 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

4 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

4 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

4 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

4 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

4 years ago