【问题标题】:How to control H2 driver version in Grails 3 Gradle project?如何在 Grails 3 Gradle 项目中控制 H2 驱动程序版本?
【发布时间】:2015-12-07 14:44:09
【问题描述】:

Grails/Gradle项目中的H2驱动版本如何控制?

在使用H2 运行Grails 3 应用程序时遇到问题我找到了这个答案:Grails accessing H2 TCP server hangs 说明这可能是由驱动程序版本差异引起的。

我的 IDE 报告 Grails 应用程序使用 1.3.176 版本的 H2,而我的服务器使用 1.4.190。所以,我想升级应用程序的H2,但找不到它的定义位置。我查找了所有项目文件,但没有找到版本定义。

更新

我现在的build.gradle:

buildscript {
    ext {
        grailsVersion = project.grailsVersion
    }
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0'
        classpath "org.grails.plugins:hibernate:4.3.10.5"
    }
}

plugins {
    id "io.spring.dependency-management" version "0.5.2.RELEASE"
}

version "0.1"
group "multipleparentsgrails"

apply plugin: "spring-boot"
apply plugin: "war"
apply plugin: "asset-pipeline"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"

ext {
    grailsVersion = project.grailsVersion
    gradleWrapperVersion = project.gradleWrapperVersion
}

assets {
    minifyJs = true
    minifyCss = true
}

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
}

dependencyManagement {
    imports {
        mavenBom "org.grails:grails-bom:$grailsVersion"
    }
    applyMavenExclusions false
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-dependencies"
    compile "org.grails:grails-web-boot"

    compile "org.grails.plugins:hibernate"
    compile "org.grails.plugins:cache"
    compile "org.hibernate:hibernate-ehcache"
    compile "org.grails.plugins:scaffolding"

    runtime "org.grails.plugins:asset-pipeline"

    testCompile "org.grails:grails-plugin-testing"
    testCompile "org.grails.plugins:geb"

    // Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
    testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'

    console "org.grails:grails-console"
}

task wrapper(type: Wrapper) {
    gradleVersion = gradleWrapperVersion
}

【问题讨论】:

    标签: java grails h2 grails-3.0


    【解决方案1】:

    您应该能够像任何其他依赖项一样指定它

    runtime "com.h2database:h2:1.4.190"

    【讨论】:

    • 在你的build.gradle下dependencies
    • 但是如果目前根本没有任何H2 描述,它现在如何工作?
    • 如果根本没有指定它必须包含在另一个依赖项中。发布您的build.gradle
    • 你可以通过 gradle 运行一个 dependencyReport 来查看它被包含在哪里。真的没关系,为更高版本添加依赖项应该可以工作。
    【解决方案2】:

    有许多依赖项可能使用 H2。 grails,hibernate,其他。

    我会进入你的项目。假设它是 $HOME/projects/myproj。

    1) 做一个依赖报告。通过管道将其输入 grep,这样您就不必费力地阅读 1,000 行报告,并查看正在使用的 H2 版本。

    cd $HOME/projects/myproj
    ./gradlew dependencies | grep 'H2'
    

    2) 找到最高版本号,然后在你的 build.gradle 中显式包含它,以强制每个依赖项使用最新版本:

    dependencies {
        // all the other dependencies
    
        runtime "com.h2database:h2:1.4.190"  // where 1.4.190 is the most
                                             // current version.  as i
                                             // type this it is 1.4.191
                                             // according to maven central
    
    }
    

    【讨论】:

      猜你喜欢
      • 2020-11-04
      • 1970-01-01
      • 1970-01-01
      • 2016-09-24
      • 1970-01-01
      • 2015-05-04
      • 2011-11-02
      • 1970-01-01
      • 2020-03-11
      相关资源
      最近更新 更多