Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Gradle with Spring Boot to get Gosling Release Train of Spring data?

How can I get the latest Gosling release train into my Gradle build file?

I used to be using the 1.1.9.RELEASE group for most of my dependencies. Now I need to fix the problem with RepositoryRestMvcConfiguration mentioned here and to do so I am trying to upgrade to the latest release of spring Data, which has fixed the bug according to the github issue I linked to.

When I added the Gosling release train dependencies I also removed the spring boot starters for spring-data-jpa and spring-data-rest thinking I might have dependency conflicts. Doing this pulled in the new jar files but now I am getting cannot find symbol errors on all my javax.persistence annotations.

Can I use the Gosling release train with the spring boot starters or do I have to figure out how to pull in all spring boot dependencies manually in order to use Gosling?

I am using Gradle 2.3.10 on Mac OS X Yosemite.

New Code

buildscript {
  ext {
    springBootVersion = '1.3.0.M3'
  }
  repositories {
    jcenter()
    mavenCentral()
    //maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
  }
  dependencies {
    classpath "io.spring.gradle:dependency-management-plugin:0.5.0.RELEASE"
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
  }
}

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

ext {
  springVersion = '4.1.6.RELEASE'
  springDataVersion = 'Gosling-RELEASE'
}

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

jar {
  baseName = 'my-data-api'
  version = '0.0.1'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
  jcenter()
  mavenCentral()
  //maven { url "https://repo.spring.io/snapshot" }
  maven { url "https://repo.spring.io/milestone" }
}

dependencies {
  compile("org.springframework.boot:spring-boot-starter-actuator:1.3.0.M3")
  compile("org.springframework.boot:spring-boot-starter-aop:1.3.0.M3")
  compile 'org.springframework.data:spring-data-jpa'
  compile 'org.springframework.data:spring-data-rest-webmvc'
  compile("org.springframework.boot:spring-boot-starter-web:1.3.0.M3")
  compile("org.springframework.boot:spring-boot-starter-jdbc:1.3.0.M3")
  compile('org.antlr:stringtemplate:4.0.2')
  compile('org.apache.commons:commons-lang3:3.0')
  compile('commons-io:commons-io:2.4')
  compile('com.ingres.jdbc:iijdbc:10.0-4.0.5')

  testCompile("org.springframework.boot:spring-boot-starter-test:1.3.0.M3")
}

Old code

buildscript {
ext {
    springBootVersion = '1.3.0.M2'
}
repositories {
    jcenter()
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
  baseName = 'my-data-api'

  version = '0.0.1'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
  jcenter()
  mavenCentral()
  maven { url "https://repo.spring.io/snapshot" }
  maven { url "https://repo.spring.io/milestone" }
}

dependencies {
  compile("org.springframework.boot:spring-boot-starter-actuator:1.2.0.RC2")
  compile("org.springframework.boot:spring-boot-starter-aop:1.1.9.RELEASE")
  compile("org.springframework.boot:spring-boot-starter-data-jpa:1.1.9.RELEASE")
  compile("org.springframework.boot:spring-boot-starter-web:1.1.9.RELEASE")
  compile("org.springframework.boot:spring-boot-starter-data-rest:1.1.9.RELEASE")
  compile("org.springframework.boot:spring-boot-starter-jdbc:1.1.9.RELEASE")
  compile('org.antlr:stringtemplate:4.0.2')
  compile('org.apache.commons:commons-lang3:3.0')
  compile('commons-io:commons-io:2.4')

  compile('com.ingres.jdbc:iijdbc:10.0-4.0.5')

  testCompile("org.springframework.boot:spring-boot-starter-test:1.1.9.RELEASE")
}

Edit:

If I put a javax persistence dependency in my build.gradle then I can successfully build and use RepositoryRestConfigurerAdapter, but I get runtime problems with dependencies missing for my entityManagerFactory

like image 990
Kent Bull Avatar asked Sep 26 '22 13:09

Kent Bull


1 Answers

If you are already using milestone versions of Spring Boot, I suggest you switch to M5. It includes Gosling-RELEASE Spring Data.

like image 141
Ilya Novoseltsev Avatar answered Sep 29 '22 23:09

Ilya Novoseltsev