-1

My Spring Boot application's spring boot parent version is 1.5. There is a custom dependency whose spring boot version is 2.0. I want to force this dependency to use spring boot 1.5 in main Spring Boot application.
Given that: Dependency's version cannot be downgraded as it is being used by other apps and cannot upgrade the spring boot main app to 2.0 from 1.5. Dependency works well for both SB 1.5 and 2.0 well. Exclusion tags were also added to exclude springboot 1.5. but it was also not successful.

Please let me know how to force the dependency to use 1.5 at run time ?

Débora
  • 5,816
  • 28
  • 99
  • 171
  • 1
    Possible duplicate of [Excluding Maven dependencies](https://stackoverflow.com/questions/9119055/excluding-maven-dependencies) – Silviu Burcea Jul 18 '19 at 11:58
  • @SilviuBurcea . This question is not about conflicts between dependencies. The issue is the parent. Also not upgrading dependencies versions. – Débora Jul 18 '19 at 12:17
  • I think you misunderstood the duplicate: it explains how to exclude a dependency of a dependency, since you have a different version already. – Silviu Burcea Jul 18 '19 at 13:40
  • What is the effect of the parent POM of the dependency? Does it lead to wrong versions of dependencies in your project? Usually, you need to care much about the parent POM version of a dependency as long as it does not define dependencies. – J Fabian Meier Jul 18 '19 at 13:56
  • Did my answer solve your question? – J Fabian Meier Jul 21 '19 at 16:01

2 Answers2

2

You cannot change the parent POM of a dependency.

You can, though, overwrite dependencies that are defined in a dependency's parent POM. This can be done using the same mechanisms as overwriting other transitive dependencies (<dependencyManagement>).

As dependencies are the only way a parent POM of a dependency contributes to your build, you have no need to change it.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
-1

You can enforce consistent dependencies in whole project with rule Dependency Convergence.

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-enforcer-plugin</artifactId>
     <version>1.3.1</version>
     <executions>
        <execution>
           <id>enforce</id>
           <configuration>
              <rules>
                 <DependencyConvergence/>
              </rules>
           </configuration>
           <goals>
              <goal>enforce</goal>
           </goals>
        </execution>
     </executions>
  </plugin>