<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How pom.xml Works A Guide with example]]></title><description><![CDATA[How pom.xml Works A Guide with example]]></description><link>https://how-pom-xml-works-practical-guide.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 19 Jun 2026 19:10:01 GMT</lastBuildDate><atom:link href="https://how-pom-xml-works-practical-guide.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Beginner's Guide to pom.xml with Real-Life Examples]]></title><description><![CDATA[Introduction to pom.xml:
pom.xml is the main file for a Maven Java project. It defines the project coordinates, such as group, artifact, and version, manages all these aspects, and configures build plugins like compiler, test, runner, and packaging. ...]]></description><link>https://how-pom-xml-works-practical-guide.hashnode.dev/beginners-guide-to-pomxml-with-real-life-examples</link><guid isPermaLink="true">https://how-pom-xml-works-practical-guide.hashnode.dev/beginners-guide-to-pomxml-with-real-life-examples</guid><category><![CDATA[maven]]></category><category><![CDATA[Java]]></category><category><![CDATA[Spring]]></category><category><![CDATA[Springboot]]></category><category><![CDATA[buildtools]]></category><dc:creator><![CDATA[Junaid Ashraf]]></dc:creator><pubDate>Sat, 20 Sep 2025 15:19:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1758381307577/d7d3ed62-4f29-4da7-9928-7c0aec0a94b5.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction-to-pomxml">Introduction to pom.xml:</h2>
<p>pom.xml is the main file for a Maven Java project. It defines the project coordinates, such as group, artifact, and version, manages all these aspects, and configures build plugins like compiler, test, runner, and packaging. In this blog, I will explain everything about pom.xml using the example of a Library Management System (Spring + JDBC + PostgreSQL), showing why it makes development easier. If you are a Java developer, you’ll be amazed at how effortlessly it handles dependencies. By using pom.xml, you get automatic dependency resolution, reproducible builds, test runs, and packaging.</p>
<h2 id="heading-why-pomxml-simplifies-life">Why pom.xml simplifies life:</h2>
<p>Maven’s pom.xml isn’t just a config file — it’s your project’s control center. Here’s how it streamlines development:</p>
<ul>
<li><p>Single centralized dependency management — add one &lt;dependency&gt;, and Maven pulls it and its transitive libraries.</p>
</li>
<li><p>Standard build lifecycle (clean, compile, test, package, install, deploy) — no ad-hoc scripts.</p>
</li>
<li><p>Plugins (compiler, surefire, spring-boot, shade) let you customize compilation, testing, and packaging.</p>
</li>
<li><p>Profiles let you switch environment-specific settings (dev vs prod) without changing code.</p>
</li>
</ul>
<h2 id="heading-dependencies-i-used-in-my-spring-projectlibrary-management-system"><strong>Dependencies I used in my Spring project(Library Management System)</strong>:</h2>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-context<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>5.3.39<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p><strong>org.springframework:spring-context:5.3.39</strong> This is the core Spring container module, responsible for Inversion of Control (IoC), bean lifecycle management, and dependency injection. It provides the ApplicationContext, which acts as a central registry for all configured beans. If you're new to Spring, think of it as a framework that wires together your components (beans) based on configuration — making your application modular, testable, and easy to manage.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-jdbc<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>5.3.39<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p><strong>org.springframework:spring-jdbc:5.3.39</strong> This module provides JDBC support through helpers like <strong>JdbcTemplate and DataSourceUtils</strong>, simplifying query execution, result mapping (<strong>RowMapper</strong>), and exception handling. Without Spring, you'd manually manage connections and write verbose DAO code. With Spring JDBC, much of that boilerplate is handled for you — making data access cleaner and more maintainable.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.junit.jupiter<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>junit-jupiter<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>5.10.0<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">scope</span>&gt;</span>test<span class="hljs-tag">&lt;/<span class="hljs-name">scope</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p><strong>org.junit.jupiter:junit-jupiter:5.10.0</strong> (scope: test) This is the core API and engine for JUnit 5, used to write and run unit tests in Java. It provides annotations like <strong>@Test</strong>, lifecycle hooks, and integration with Maven’s test phase — making it easy to structure and automate your test cases.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.mockito<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>mockito-core<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>5.12.0<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">scope</span>&gt;</span>test<span class="hljs-tag">&lt;/<span class="hljs-name">scope</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p><strong>org.mockito:mockito-core:5.12.0</strong> (scope: test) Mockito is a popular Java library for creating mock objects in unit tests. It allows you to simulate dependencies and verify interactions, making it easier to test components in isolation without relying on real implementations.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>javax.servlet<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>javax.servlet-api<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>4.0.1<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">scope</span>&gt;</span>test<span class="hljs-tag">&lt;/<span class="hljs-name">scope</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p><strong>javax.servlet:javax.servlet-api:4.0.1</strong> (scope: test) This dependency provides the core Servlet API, including interfaces like <strong>HttpServletRequest</strong> and <strong>HttpServletResponse</strong>. It’s essential for unit testing web controllers in Spring MVC applications, allowing you to simulate HTTP requests and responses without deploying to a servlet container.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.postgresql<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>postgresql<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>42.7.3<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p><strong>org.postgresql:postgresql:42.7.3</strong> This is the official JDBC driver for PostgreSQL, enabling Java applications to connect to and interact with PostgreSQL databases. It’s required by <strong>DataSource</strong> configurations in Spring JDBC or JPA setups to perform database operations.</p>
<h2 id="heading-dependencies-if-you-are-working-with-a-springboot-project"><strong>Dependencies: If you are working with a SpringBoot Project:</strong></h2>
<h3 id="heading-parent-declaration">Parent Declaration:</h3>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">parent</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-starter-parent<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>3.1.4<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span> 
    <span class="hljs-tag">&lt;<span class="hljs-name">relativePath</span>/&gt;</span> 
<span class="hljs-tag">&lt;/<span class="hljs-name">parent</span>&gt;</span>
</code></pre>
<p>Without the parent, you'd have to manually manage plugin versions, dependency versions, and lifecycle configurations — which can be error-prone and time-consuming. The parent <strong>pom.xml</strong> acts like a <strong>trusted blueprint</strong> for building Spring Boot apps efficiently.</p>
<h2 id="heading-plugins-i-used-in-my-projectlibrary-management-system">Plugins I used in my project(Library Management System):</h2>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">plugin</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>maven-compiler-plugin<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>3.11.0<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">configuration</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">source</span>&gt;</span>17<span class="hljs-tag">&lt;/<span class="hljs-name">source</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">target</span>&gt;</span>17<span class="hljs-tag">&lt;/<span class="hljs-name">target</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">configuration</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">plugin</span>&gt;</span>
</code></pre>
<p><strong>maven-compiler-plugin</strong> This plugin handles Java compilation during the Maven build process. The <strong>&lt;source&gt;</strong> and <strong>&lt;target&gt;</strong> tags define the language level — in your case, Java 17. Make sure your system’s JDK matches this version to avoid compatibility issues.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">plugin</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>maven-surefire-plugin<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>3.1.2<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">configuration</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">useModulePath</span>&gt;</span>false<span class="hljs-tag">&lt;/<span class="hljs-name">useModulePath</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">configuration</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">plugin</span>&gt;</span>
</code></pre>
<p><strong>maven-surefire-plugin</strong> This plugin runs unit tests during the Maven build process. In some cases, adding <strong>useModulePath=false</strong> helps avoid issues related to JPMS (Java Platform Module System), especially when working with older or non-modular libraries. If your project uses the traditional classpath setup, this configuration may not be necessary.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Maven’s <strong>pom.xml.</strong> It isn’t just a configuration file — it’s the backbone of your Java project’s build and dependency management. Whether you're working with Spring Boot, JDBC, JUnit, or packaging tools, a well-structured <strong>pom.xml</strong> simplifies development, testing, and deployment. By understanding each plugin and dependency, you gain full control over your project lifecycle and ensure maintainability across environments.</p>
<p>If you're building a Library Management System or any modular Java application, mastering <strong>pom.xml</strong> is a must — and once you do, your workflow becomes smoother, cleaner, and far more scalable.</p>
<h2 id="heading-github-repository">📦 GitHub Repository</h2>
<p>You can explore the complete project here: <a target="_blank" href="https://github.com/Junaid-Ashraf-56/Library_Management_System-Spring-">Library Management System</a></p>
]]></content:encoded></item></channel></rss>