Import Dependency Management with Exclusion

Exclusions are still not implemented for dependencyManagement as of current maven 3.6.3. However you can include a project specific "Bill Of Materials" (BOM) as the first dependency in the dependencyManagement section, i.e.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>my-group</groupId>
            <artifactId>my-group-project-bom</artifactId>
            <version>${project.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

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

You can then specify all the necessary artifact versions in your project BOM which will take precedence over the spring-boot dependency versions.


Exclusion at import won't work, try excluding it from the actual user of the dependency

Tags:

Maven