logo

Spring web app tutorial extras: BOM dependency

How to use Maven Spring Framework BOM dependency?

If you use different Spring frameworks like Spring Security and Spring Data JPA, you will notice, that each version of each framework depends on some version of base Spring Framework libraries.

This can create a major problem, because you can easily mismatch versions. This will result in a nasty errors during application startup.

How to resolve this issue? You can either add all Spring dependencies in pom.xml and ensure that in classpath are correct Spring versions, or you can use Spring bom (Bill of Materials) dependency:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>${org.springframework.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

If you use this dependency, then you don't specify the Spring version inside other Spring Framework dependencies and this bom dependency will take care of managing correct Spring Framework versions, so you won't have to do it manually.


comments powered by Disqus

rss

Free online Java web application examples

Want to develop whole web applications which use database, security and more? See my github account, where are lot's of example projects:
github

Search