运行 geb 测试 gradle 2.3 - HashMap$Entry 异常
running geb test with gradle 2.3 - HashMap$Entry exception
我正尝试通过 gradle 运行 geb 测试。我已经安装了这些
java 版本 "1.8.0_31"
Groovy版本:2.4.0
Gradle 2.3
但是我在 运行 进行测试时遇到了这个错误。
Exception in thread "main" java.lang.NoClassDefFoundError: java/util/HashMap$Ent
ry
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2693)
运行 一个简单的 groovy 脚本,上面的设置和下面的 Build.gradle 就可以了。
Build.gradle 看起来像这样:
buildscript {
repositories {
jcenter()
}
}
apply plugin: 'java'
apply plugin: 'groovy'
repositories {
jcenter()
mavenCentral()
}
dependencies {
def seleniumVersion = "2.45.0"
def phantomJsVersion = '1.1.0'
// selenium drivers
compile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
compile "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
compile("com.github.detro.ghostdriver:phantomjsdriver:$phantomJsVersion") {
transitive = false
}
// geb
compile 'org.codehaus.geb:geb-core:0.7.2'
compile 'org.codehaus.geb:geb-spock:0.7.2'
// spock
compile 'org.spockframework:spock-core:0.6-groovy-1.8'
//junit
testCompile group: 'junit', name: 'junit', version: '4.7'
}
task runGebScript (dependsOn: 'classes', type: JavaExec) {
main = 'test'
classpath = sourceSets.main.runtimeClasspath
}
有人可以帮忙吗。
有些东西正在尝试使用内部 class HashMap.Entry
,它不再存在于 Java 8 中。如果没有完整的堆栈跟踪,很难说出在哪里。
但是,您正在使用此版本的 spock:org.spockframework:spock-core:0.6-groovy-1.8
。该版本与 groovy 2.0+ 不兼容。尝试将依赖项更新为 org.spockframework:spock-core:1.0-groovy-2.4
.
根据您包含的构建的 Gradle 依赖性报告,用于 testCompile
配置的 Groovy 版本是 1.8.5。只有 groovy 2.x 与 JDK8 兼容。我会按照 ataylor 的建议去做,并修改 Spock 版本。如果您使用 1.0-groovy-2.4,那么您将使用 Groovy 2.4.1。另外,我建议您在使用时更新 Geb 的版本——最新版本是 0.10.0。您的依赖版本已经过时了。
我正尝试通过 gradle 运行 geb 测试。我已经安装了这些
java 版本 "1.8.0_31"
Groovy版本:2.4.0
Gradle 2.3
但是我在 运行 进行测试时遇到了这个错误。
Exception in thread "main" java.lang.NoClassDefFoundError: java/util/HashMap$Ent
ry
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2693)
运行 一个简单的 groovy 脚本,上面的设置和下面的 Build.gradle 就可以了。
Build.gradle 看起来像这样:
buildscript {
repositories {
jcenter()
}
}
apply plugin: 'java'
apply plugin: 'groovy'
repositories {
jcenter()
mavenCentral()
}
dependencies {
def seleniumVersion = "2.45.0"
def phantomJsVersion = '1.1.0'
// selenium drivers
compile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
compile "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
compile("com.github.detro.ghostdriver:phantomjsdriver:$phantomJsVersion") {
transitive = false
}
// geb
compile 'org.codehaus.geb:geb-core:0.7.2'
compile 'org.codehaus.geb:geb-spock:0.7.2'
// spock
compile 'org.spockframework:spock-core:0.6-groovy-1.8'
//junit
testCompile group: 'junit', name: 'junit', version: '4.7'
}
task runGebScript (dependsOn: 'classes', type: JavaExec) {
main = 'test'
classpath = sourceSets.main.runtimeClasspath
}
有人可以帮忙吗。
有些东西正在尝试使用内部 class HashMap.Entry
,它不再存在于 Java 8 中。如果没有完整的堆栈跟踪,很难说出在哪里。
但是,您正在使用此版本的 spock:org.spockframework:spock-core:0.6-groovy-1.8
。该版本与 groovy 2.0+ 不兼容。尝试将依赖项更新为 org.spockframework:spock-core:1.0-groovy-2.4
.
根据您包含的构建的 Gradle 依赖性报告,用于 testCompile
配置的 Groovy 版本是 1.8.5。只有 groovy 2.x 与 JDK8 兼容。我会按照 ataylor 的建议去做,并修改 Spock 版本。如果您使用 1.0-groovy-2.4,那么您将使用 Groovy 2.4.1。另外,我建议您在使用时更新 Geb 的版本——最新版本是 0.10.0。您的依赖版本已经过时了。