【问题标题】:Multi-modules project with Spring Boot Gradle plugin带有 Spring Boot Gradle 插件的多模块项目
【发布时间】:2016-06-11 12:47:23
【问题描述】:

多模块项目的模块具有以下依赖项:web->core->persistence

我在 web 模块中添加了 spring-boot-gradle-plugin:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
    }
 }
 apply plugin: 'spring-boot'

由于 spring-boot-gradle-plugin 下载旧的休眠版本,我在持久性模块中有重复。

Image

我试图覆盖 web 模块中的休眠依赖项并且它正在工作:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
    }
}

apply plugin: 'spring-boot'

dependencies {
    compile project(':core')
    //Other dependencies

    compile "org.hibernate:hibernate-core:${hibernateVersion}"
    compile "org.hibernate:hibernate-validator:${hibernateValidatorVersion}"
    compile "org.hibernate:hibernate-entitymanager:${hibernateVersion}"
}

Image

为什么插件会下载旧的hibernate版本?是否有可能从 spring-boot-gradle-plugin 中排除旧的休眠版本?

【问题讨论】:

    标签: spring hibernate dependencies multi-module spring-boot-gradle-plugin


    【解决方案1】:

    首先,考虑将您的插件版本升级到 1.5.9.RELEASE,这是当前的稳定版本。另外,根据文档考虑使用 Spring data jpa 依赖项,

    spring-boot-starter-data-jpa POM 提供了一种快速获取 开始了。它提供了以下关键依赖项:

    1. Hibernate — 最流行的 JPA 实现之一。
    2. Spring Data JPA — 使实现基于 JPA 的存储库变得容易。
    3. Spring ORMs — 来自 Spring 框架的核心 ORM 支持。

    默认情况下,Spring Boot 使用 Hibernate 5.0.x。不过也是 如果您愿意,可以使用 4.3.x 或 5.2.x。请参考 Hibernate 4 和 Hibernate 5.2 示例以了解如何执行此操作。

    您可以找到链接here。它还向您展示了如何覆盖它以在 maven 项目中使用更多当前版本,这与您所做的没有太大区别。

    【讨论】:

      猜你喜欢
      • 2016-02-15
      • 1970-01-01
      • 2017-08-16
      • 2017-05-31
      • 2017-06-27
      • 1970-01-01
      • 1970-01-01
      • 2019-01-30
      • 2018-10-07
      相关资源
      最近更新 更多