How to exclude transitive spring-boot dependencies from maven import scope

My Spring Boot app pom app has the following: documentation :

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

I need to use use dependencyManagement and <scope>import</scope> because I need to use the standard corporate pom base.

However, the exclusion of transitive dependencies spring-boot-dependencies not ruled out. In my particular case, Spring Boot 1.2.1.RELEASE brings a version of Jetty that is too new in relation to some of my other <dependencies> . I tried using <exclusion> forms:

  <dependencyManagement> <dependencies> <!-- Spring --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>${spring-boot.version}</version> <type>pom</type> <scope>import</scope> <!-- Doesn't work --> <exclusions> <exclusion> <groupId>org.eclipse.jetty</groupId> <artifactId>*</artifactId> </exclusion> </exclusions> </dependency> </dependencies> </dependencyManagement> 

using Maven 3.2.1 wildcard support , but this does not seem to take effect.

Is there a solution to this problem besides explicitly overriding all Jetty dependencies? There are many Jetty libraries, and this approach will be rather fragile. Also, it looks like I will need to do the same with Jetty's transient dependencies.

+6
source share
1 answer

It seems to be impossible using the Maven import scope :

The import area can be used to enable dependency management information from the remote POM in the current project. One of the limitations of this is that it does not allow additional exclusion for a project with several modules .

Similarly, there is confirmation from the Spring Download Documentation :

If you added spring-boot dependencies to your own dependencyManagement with <scope>import</scope> , you need to redefine the artifact yourself [...].

+1
source

Source: https://habr.com/ru/post/980960/


All Articles