Geb-Spock使用错误的Groovy版本

如何解决Geb-Spock使用错误的Groovy版本

当我尝试使用以下功能创建功能测试时:

grails create-functional-test acceptance.tests.Logout

我收到此错误,因为Spock尝试使用错误的Groovy版本:

|错误无法编译GenerateAsyncController.groovy:启动失败: 无法实例化在jar:file:/Users/reinaldoluckman/.gradle/caches/modules-2/files-2.1/org.spockframework/spock-core/2.0-M2-groovy指定的全局转换类org.spockframework.compiler.SpockTransform -3.0 / 396867de1bbbe11e85e197c22f0e6de07643185a / spock-core-2.0-M2-groovy-3.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation由于异常org.spockframework.util.IncompatibleGroovyVersionException:Spock编译器插件无法执行,因为Spock 2.0.0-M2-groovy-3.0与Groovy 2.5.6不兼容。有关更多信息,请参见http://docs.spockframework.org Spock工件:文件:/Users/reinaldoluckman/.gradle/caches/modules-2/files-2.1/org.spockframework/spock-core/2.0-M2-groovy-3.0/396867de1bbbe11e85e197c22f0e6de07643185a/spock-core-2.0-M2-groovy -3.0.jar Groovy工件:文件:/Users/reinaldoluckman/.sdkman/candidates/grails/4.0.4/lib/org.codehaus.groovy/groovy/jars/groovy-2.5.6.jar

但是在我的项目中,只有Groovy 3是一个库。

这是我的build.gradle:


buildscript {
    repositories {
        jcenter()
        mavenCentral()
        mavenLocal()
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.2.5"
        classpath "org.grails.plugins:hibernate5:${gormVersion - '.RELEASE'}"
        classpath "org.grails.plugins:views-gradle:2.1.0.M1"
        classpath "gradle.plugin.com.energizedwork.webdriver-binaries:webdriver-binaries-gradle-plugin:$webdriverBinariesVersion"
    }
}

plugins {
    id "com.moowork.node" version "1.1.1"
    id "com.github.ben-manes.versions" version "0.33.0"
}

version "0.1"
group "test_project"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"org.grails.plugins.views-json"
apply plugin:"asset-pipeline"
apply plugin:"io.spring.dependency-management"
apply plugin:"com.energizedwork.webdriver-binaries"

repositories {
    jcenter()
    mavenCentral()
    mavenLocal()
    maven { url "https://plugins.gradle.org/m2/" }
    maven { url "https://repo.grails.org/grails/core" }
}

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

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

dependencies {

    developmentOnly("org.springframework.boot:spring-boot-devtools")

    implementation "org.springframework.boot:spring-boot-starter-logging"
    implementation "org.springframework.boot:spring-boot-autoconfigure"
    implementation "org.springframework.boot:spring-boot-starter-actuator"
    implementation "org.springframework.boot:spring-boot-starter-tomcat"
    implementation "org.grails:grails-dependencies"
    implementation "org.grails:grails-web-boot"
    implementation "org.grails:grails-core"
    implementation "org.grails:grails-datastore-rest-client:6.1.12.RELEASE"
    implementation "org.grails:grails-logging"
    implementation "org.grails.plugins:cache"
    implementation "org.grails.plugins:scaffolding"
    implementation "org.grails.plugins:hibernate5:${gormVersion - '.RELEASE'}"
    implementation "org.hibernate:hibernate-ehcache"
    console "org.grails:grails-console"
    profile "org.grails.profiles:web"
    runtime("org.springframework.boot:spring-boot-properties-migrator")
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:3.2.5"
    runtime "com.h2database:h2"

    testImplementation "org.grails:grails-gorm-testing-support:$testingVersion"
    testImplementation "org.grails:grails-web-testing-support:$testingVersion"
    testImplementation "org.grails.plugins:geb"
    testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
    testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
    testRuntime "org.seleniumhq.selenium:selenium-safari-driver:$seleniumSafariDriverVersion"
    testImplementation "org.seleniumhq.selenium:selenium-remote-driver:$seleniumVersion"
    testImplementation "org.seleniumhq.selenium:selenium-api:$seleniumVersion"
    testImplementation "org.seleniumhq.selenium:selenium-support:$seleniumVersion"

    implementation "com.github.jsimone:webapp-runner:9.0.27.1"
    implementation "org.grails.plugins:spring-security-core:4.0.2"
    implementation "org.grails.plugins:spring-security-rest:3.0.1"
    implementation "org.grails.plugins:postgresql-extensions:5.3.0"
    implementation "org.grails.plugins:views-json:2.1.0.M1"
    implementation "org.grails.plugins:mail:3.0.0"
    implementation 'io.github.http-builder-ng:http-builder-ng-core:1.0.3'
    runtime "org.postgresql:postgresql:42.2.11"

    // Para tirar os warnings do application.yml
    implementation "org.springframework.boot:spring-boot-configuration-processor"
}

webdriverBinaries {
    chromedriver "$chromeDriverVersion"
    geckodriver "$geckodriverVersion"
}

tasks.withType(Test) {
    systemProperty "geb.env",System.getProperty('geb.env')
    systemProperty "geb.build.reportsDir",reporting.file("geb/integrationTest")
    systemProperty "webdriver.chrome.driver",System.getProperty('webdriver.chrome.driver')
    systemProperty "webdriver.gecko.driver",System.getProperty('webdriver.gecko.driver')
}

springBoot {
    mainClassName = 'test_project.Application'
}

bootRun {
    jvmArgs('-Dspring.output.ansi.enabled=always')
    sourceResources sourceSets.main
}


assets {
    minifyJs = true
    minifyCss = true
    includes = ["fonts/*"]
}

processResources.dependsOn(['npmInstall','npm_run_bundle'])
assetCompile.dependsOn(['npmInstall','npm_run_bundle'])


task stage() {
    dependsOn clean,war
}

tasks.stage.doLast() {
    delete fileTree(dir: "build/distributions")
    delete fileTree(dir: "build/assetCompile")
    delete fileTree(dir: "build/distributions")
    delete fileTree(dir: "build/libs",exclude: "*.war")
}
war.mustRunAfter clean

task copyToLib(type: Copy) {
    into "$buildDir/server"
    from(configurations.compile) {
        include "webapp-runner*"
    }
}

stage.dependsOn(copyToLib)


这里是gradle.properties:

grailsVersion=4.1.0.M2
groovyVersion=3.0.6
gormVersion=7.1.0.M2
gradleWrapperVersion=6.6.1
testingVersion=2.2.0.M2
gebVersion=3.4
seleniumVersion=3.12.0
webdriverBinariesVersion=1.4
chromeDriverVersion=86.0.4240.22
geckodriverVersion=0.23.0
seleniumSafariDriverVersion=3.14.0

如何使Spock(这是Geb的传递依赖项)使用Groovy 3(已经在我的类路径中)了?

谢谢。

解决方法

快速检查表明current master of Geb仍然取决于spock-1.3-groovy-2.5,因此我不确定是否可以将Geb与Spock 2.0一起使用。但是看起来好像不能,请参见Geb issue #619。因此,您现在想坚持使用Spock 1.3和Groovy 2.5。

,

在Grails 4.1.0.M2中,grails create-functional-test acceptance.tests.Logout很有魅力。但是我做了一些额外的步骤(如@kriegaex在评论中所说的那样,避免流血的边缘)。

我所做的是:

  1. 已更新为Grails 4.1.0.M2
  2. 回滚到Gradle 5.1.1(推荐版本)
  3. 重新创建的gradle包装器(gradle wrapper --gradle-version 5.1.1
  4. 继续使用Groovy 3.0.6(3.0.3给出了依赖项不兼容)
  5. 其他一切都来自与Grails 4.1.0.M2相关联的Maven BOM(如我在问题中的build.gradle所示)

但是问题是Grails 4.1.0.M2随附了Spock 2.0-M2-groovy-3.0,从而解决了@kriegaex answer中指出的问题。

此外,感谢@JeffScottBrow提供评论中的提示。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-