首页 文章

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

提问于
浏览
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版本?

1 回答

  • 0

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

    spring-boot-starter-data-jpa POM提供了一种快速入门方式 . 它提供了以下关键依赖项:Hibernate - 最受欢迎的JPA实现之一 . Spring Data JPA - 使实现基于JPA的存储库变得容易 . Spring ORMs - 来自Spring Framework的核心ORM支持 . 默认情况下,Spring Boot使用Hibernate 5.0.x.但是,如果您愿意,也可以使用4.3.x或5.2.x.请参阅Hibernate 4和Hibernate 5.2示例以了解如何执行此操作 .

    你可以找到链接here . 它还向您展示了如何覆盖它以在maven项目中使用更多当前版本,而该项目并未完成 .

相关问题