使用Spring Boot Gradle插件的多模块项目

问题描述 投票:1回答:1

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

我在网络模块中添加了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下载旧的hibernate版本时,我在持久性模块中有重复项。

Image

我试图覆盖Web模块中的hibernate依赖项,它正在工作:

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中排除旧的hibernate版本?

spring hibernate dependencies multi-module spring-boot-gradle-plugin
1个回答
0
投票

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

spring-boot-starter-data-jpa POM提供了一种快速入门方式。它提供以下关键依赖项:

  1. Hibernate - 最受欢迎的JPA实现之一。
  2. Spring Data JPA - 使实现基于JPA的存储库变得容易。
  3. Spring ORMs - 来自Spring Framework的核心ORM支持。

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

你可以找到链接here。它还向您展示了如何覆盖它以在maven项目中使用更多当前版本,这与您所做的完全不同。

© www.soinside.com 2019 - 2024. All rights reserved.