【问题标题】:How to use Gradle with Spring Boot to get Gosling Release Train of Spring data?如何使用 Gradle 和 Spring Boot 来获取 Spring 数据的 Gosling Release Train?
【发布时间】:2015-10-08 21:13:31
【问题描述】:

如何将最新的 Gosling 发布系列放入我的 Gradle 构建文件?

我曾经使用 1.1.9.RELEASE 组来处理我的大部分依赖项。现在我需要解决RepositoryRestMvcConfiguration 提到的here 的问题,为此我正在尝试升级到最新版本的spring Data,它已根据我链接到的github问题修复了该错误。

当我添加 Gosling 发布序列依赖项时,我还删除了 spring-data-jpa 和 spring-data-rest 的 spring boot 启动器,我认为我可能存在依赖项冲突。这样做会拉入新的 jar 文件,但现在我的所有 javax.persistence 注释都出现 cannot find symbol 错误。

我可以将 Gosling 发布系列与 Spring Boot 启动器一起使用,还是我必须弄清楚如何手动拉入所有 Spring Boot 依赖项才能使用 Gosling?

我在 Mac OS X Yosemite 上使用 Gradle 2.3.10。

新代码

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")
}

旧代码

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")
}

编辑:

如果我在 build.gradle 中放置 javax 持久性依赖项,那么我可以成功构建和使用 RepositoryRestConfigurerAdapter,但我会遇到运行时问题,因为我的 entityManagerFactory 缺少依赖项

【问题讨论】:

    标签: spring gradle spring-boot spring-data


    【解决方案1】:

    如果您已经在使用 Spring Boot 的里程碑版本,我建议您切换到 M5。它包括 Gosling-RELEASE Spring Data。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-20
      • 2020-12-30
      • 1970-01-01
      • 2019-10-03
      • 2022-10-15
      • 2020-06-02
      • 2018-04-27
      • 2020-07-11
      相关资源
      最近更新 更多