gpt4 book ai didi

spring-cloud-contract - 为什么使用 Spring Cloud Contract 在 Gradle、Kotlin、Spring Boot 应用程序中compileTestGroovy 失败

转载 作者:行者123 更新时间:2023-12-03 08:57:12 26 4
gpt4 key购买 nike

Spring Cloud Contract Gradle 插件 (2.0.2.RELEASE)

我的 Kotlin 项目,一个 Spring Boot 2.0.5.RELEASE 应用程序,在 src/test/下有一个 Groovy 合约文件resources/contracts 和 Base 测试类 com.mycompany.practice.base. Producer.PracticeMessagingBase 成功生成了 ContractVerifierTest 并且打开该文件表明 IntelliJ 很高兴使用该文件,但在 compileTestGroovy

上运行 ./gradlew clean build 失败
> Task :compileTestGroovy FAILED
file or directory '/Users/abc/Documents/code/dev/practice-service/src/test/groovy', not found
file or directory '/Users/abc/Documents/code/dev/practice-service/src/test/groovy', not found
Task ':compileTestGroovy' is not up-to-date because:
Task has failed previously.
Excluding []
file or directory '/Users/abc/Documents/code/dev/practice-service/src/test/groovy', not found
Starting process 'Gradle Worker Daemon 1'. Working directory: /Users/abc/.gradle/workers Command: /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/bin/java -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=GB -Duser.language=en -Duser.variant -cp /Users/abc/.gradle/caches/4.7/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Worker Daemon 1'
Successfully started process 'Gradle Worker Daemon 1'
Started Gradle worker daemon (0.458 secs) with fork options DaemonForkOptions{executable=/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/bin/java, minHeapSize=null, maxHeapSize=null, jvmArgs=[], classpath=[/Users/abc/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-ant/2.4.15/2faf2c49f25ce9868b2eed1aa7dc1ecd98d33353/groovy-ant-2.4.15.jar, /Users/abc/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-groovydoc/2.4.15/7bace00f98542934e10c069d067df6e77e17f6cd/groovy-groovydoc-2.4.15.jar, /Users/abc/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-templates/2.4.15/b5cbe971f2950452c1d431ea0135dd8de2d5f58e/groovy-templates-2.4.15.jar, /Users/abc/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-xml/2.4.15/40865f59469e6b0808c9c304bd17038997220c72/groovy-xml-2.4.15.jar, /Users/abc/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy/2.4.15/74b7e0b99526c569e3a59cb84dbcc6204d601ee6/groovy-2.4.15.jar, /Users/abc/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-junit/1.9.4/b063757dacaa716b643c2f9270e469183636ff11/ant-junit-1.9.4.jar, /Users/abc/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant/1.9.4/6d473e8653d952045f550f4ef225a9591b79094a/ant-1.9.4.jar, /Users/abc/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-launcher/1.9.4/334b62cb4be0432769679e8b94e83f8fd5ed395c/ant-launcher-1.9.4.jar, /Users/abc/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-antlr/1.9.4/4cf30025981dc2344324a0ef0e40063c3ef08f0a/ant-antlr-1.9.4.jar, /Users/abc/.gradle/wrapper/dists/gradle-4.7-all/4cret0dgl5o3b21weaoncl7ys/gradle-4.7/lib/ant-1.9.9.jar, /Users/abc/.gradle/wrapper/dists/gradle-4.7-all/4cret0dgl5o3b21weaoncl7ys/gradle-4.7/lib/ant-launcher-1.9.9.jar], keepAliveMode=SESSION}.
Compiling with JDK Java compiler API.
/Users/abc/Documents/code/dev/practice-service/build/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java:3: error: package com.mycompany.practice.base.producer does not exist
import com.mycompany.practice.base.producer.PracticeMessagingBase;
^
/Users/abc/Documents/code/dev/practice-service/build/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java:16: error: cannot find symbol
public class ContractVerifierTest extends PracticeMessagingBase {
^
symbol: class PracticeMessagingBase
/Users/abc/Documents/code/dev/practice-service/build/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java:24: error: cannot find symbol
process();
^
symbol: method process()
location: class ContractVerifierTest
3 errors
startup failed:
Compilation failed; see the compiler error output for details.

1 error

:compileTestGroovy (Thread[Task worker for ':',5,main]) completed. Took 1.807 secs.

我可能做错了什么吗?

最佳答案

如果您查看失败的任务 - 它是 compileTestGroovy。由于 Groovy 可以编译 java,因此它会尝试编译基类。然而,它无法真正编译基类,因为它无法访问 Kotlin 的基类。只需在 build.gradle 中设置 compileTestGroovy.enabled = false ,一切都会正常工作

关于spring-cloud-contract - 为什么使用 Spring Cloud Contract 在 Gradle、Kotlin、Spring Boot 应用程序中compileTestGroovy 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54339399/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com