1. Overview

In this article, we learn how we can include or configure maven dependency without parent pom. In some organization might have their own parent pom so we can not use multiple parent pom in the same maven project. Using parent pom is automatically maintaining versions of dependencies, for example in the below example, we have added spring-boot-starter-web but haven’t specified the version but still, spring boot will automatically take an appropriate version of spring-boot-starter-web. Spring also provides advantages without parent pom as well.

2. Without parent pom configurations

We require two updates in pom.xml as like:

  1. Include spring-boot-dependencies with the appropriate version and make sure that scope=import which help us to maintain dependency management.
  2. Add repackage in the execution goals to generate jar or war based on spring boot packaging format. Otherwise, it may generate an error like  no main manifest attribute, in spring-boot-example-1.0-SNAPSHOT.jar when we try to run the application using java -jar spring-boot-example-1.0-SNAPSHOT.jar
<?xml version="1.0" encoding="UTF-8"?>
<project 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">

    <description>Spring boot without parent pom</description>
    <!-- Inherit defaults from Spring Boot -->


    <!-- Package as an executable jar -->

3. Conclusion

In this article, we learned that we can configure spring boot application without spring-boot-starter-parent parent pom. We also learned that the main advantage of parent pom for dependency and it’s version management.

4. Source Code

5. References

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *