Search code examples
gradleneo4jbuild.gradlespring-data-neo4jneo4j-ogm

Spring Data Neo4j OGM Gradle Dependency Issues


I am trying to manage my spring dependencies using gradle and the spring dependency management plugin. Currently this brings down version 5.0.3.RELEASE of spring-data-neo4j which according to the pom here, should bring down version 3.0.3 of the neo4j-ogm, but instead it brings down version 2.1.5. This means that even though I've followed the docs to the letter about configuration that the ConfigurationBuilder symbol is not found. Any help would be greatly appreciated. I am currently using gradle 4.4.1

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://repo.spring.io/plugins-snapshot' }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.8.RELEASE")
        classpath 'io.spring.gradle:dependency-management-plugin:1.0.5.BUILD-SNAPSHOT'
    }
}

plugins {
    id "io.spring.dependency-management" version "1.0.4.RELEASE"
}


apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: "io.spring.dependency-management"

ext {
    springVersion = '5.0.3.RELEASE'
    springDataVersion = 'Kay-SR3'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework:spring-framework-bom:${springVersion}"
        mavenBom "org.springframework.data:spring-data-releasetrain:${springDataVersion}"
    }
}

repositories {
    mavenCentral()
    maven {
        url 'https://repo.spring.io/libs-release'
    }
}


dependencies {
    compile group: "org.springframework.boot", name: "spring-boot-starter-web"
    compile group: "org.springframework.boot", name: "spring-boot-starter-security"
    compile group: "org.springframework", name: "spring-aspects"
    compile group: "org.springframework.data", name: "spring-data-neo4j"

    compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310'

    testCompile group: "org.springframework.boot", name: "spring-boot-starter-test"
    testCompile group: "org.neo4j", name: "neo4j-ogm-embedded-driver", version: "3.1.0"

}

Solution

  • You are using the spring-boot-gradle-plugin with version 1.5.8.RELEASE. This will pull in the version 4 of SDN and its dependency OGM 2.1.x when you declare the dependency here compile group: "org.springframework.data", name: "spring-data-neo4j".

    The only solution at this point is to use Spring Boot 2 RC1. If you would include SDN with its dependencies to Spring Data commons and Spring Framework 5 you will mess up your class path because Spring Boot 1 is based on Spring Framework 4.

    Background: Tried it once to integrate SDN 5.x in Spring Boot 1 but it did not work out, you will lose all benefits of Spring Boot since you have to deactivate pretty everything.