2015-12-07 58 views
0

如何在Grails/Gradle項目中控制H2驅動程序版本?如何控制Grails 3 Gradle項目中的H2驅動程序版本?

運行有問題Grails 3應用程序H2我發現這個答案:Grails accessing H2 TCP server hangs說明它可能是由驅動程序版本的差異引起的。

我的IDE報告Grails應用程序使用1.3.176版本的H2,而我的服務器有1.4.190。所以,我想升級應用程序的H2,但無法找到它的定義位置。我找到了所有的項目文件,發現沒有版本定義。

UPDATE

我目前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 
} 

回答

4

您應該能夠像任何其他依賴其指定

runtime "com.h2database:h2:1.4.190"

+0

凡註明呢? – Dims

+0

在'dependency'下的'build.gradle'中 –

+0

但是如果現在沒有任何'H2'描述,它現在如何工作? – Dims

0

有可能使用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 

}