如何在H2
/ Grails
项目中控制Gradle
驱动程序版本?
使用Grails 3
运行H2
应用时遇到问题我找到了这个答案: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
}
答案 0 :(得分:4)
您应该能够像任何其他依赖项一样指定它
runtime "com.h2database:h2:1.4.190"
答案 1 :(得分:0)
有许多可能使用H2的依赖项。 grails,hibernate,others。
我会进入你的项目。让我们说它是$ 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
}