0

I am migrating everything to spring-boot version 1.4.3.RELEASE.

Before the migration I was already using spring-data-solr version 2.1.0.RELEASE.

After introduction of spring boot i started noticing some errors, missing methods etc...

So i did some digging and found that within spring boot dependencies, spring-data-releasetrain uses older version of spring-data-solr than the version that is mandatory for me.

I have attempted to redeclare dependency with the version in my pom.xml, with no luck.

What is odd is that when i check my build path under the maven dependencies, the dependency is right for spring-data-solr version 2.1.0.RELEASE. So this does not cause any compile time issues, this happens only at run time...

I was wondering whether i can just exclude spring-data-solr and reimport my own? or is there better way to manage that?

zalis
  • 1,191
  • 1
  • 11
  • 20

1 Answers1

0

Yes you can exclude the unwanted versions and reimport your own. But this makes only sense, if your version of spring-data-solr is compatible with the spring-boot version you are using, at compile-time as well as at run-time.

The easiest way to do this, is to declare the desired version in the dependencyManagement section of your pom. See introduction-to-dependency-mechanism

dependency management takes precedence over dependency mediation for transitive dependencies

Which means, the version you declare in dependency management should override the versions from transitive dependencies.

I had constellations, where this was not sufficient and I still found the unwanted version in my classpath. If this happens, you have to exclude that unwanted dependency.

In Maven an exclusion looks like this :

           <dependency>
            <groupId>org.springframework.security.oauth</groupId>
            <artifactId>spring-security-oauth2</artifactId>
            <version>2.0.7.RELEASE</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

In the above code I am excluding spring-beans, so it is not introduced in the unwanted version required by spring-security-oauth2. You need to do this for all dependencies, that somehow tear in your spring-data-solr in an unwanted version.

Your best friend when doing this is

mvn dependency:tree -Dverbose -Dincludes=org.springframework.data:spring-data-solr

Which shows you exactly, which dependencies your project has to spring-data-solr and why they are there. See Maven for details

So you make mvn dependency:tree, add exclusion and repeat until you have no dependency to the unwanted version anymore.

Than finally you add once the dependency to the desired version.

  • Thanks for your answer, fortunately spring has released 1.5 version in the last couple of days.It has the right version of solr that i need. its a clean fix for me. Ill still mark your answer as correct – zalis Jan 31 '17 at 10:29