gpt4 book ai didi

gradle - 在类型为DefaultDependencyHandler的对象上找不到参数[org.hibernate:hibernate:5.3.7.FINAL]的方法intTestImplementation()

转载 作者:行者123 更新时间:2023-12-03 05:40:00 25 4
gpt4 key购买 nike

我正在尝试在Gradle 5.0中配置集成测试。

我看到错误

Could not find method intTestImplementation() for arguments [org.hibernate:hibernate:5.3.7.FINAL] on object of type DefaultDependencyHandler.

我说 intTestImplementation时可以看到 gradle dependencies
我正在尝试添加一个依赖项
intTestImplementation 'org.hibernate:hibernate:5.3.7.FINAL'
task integrationTest(type: Test) {
description = 'Runs integration tests.'
group = 'verification'

testClassesDirs = sourceSets.intTest.output.classesDirs
classpath = sourceSets.intTest.runtimeClasspath
shouldRunAfter test
}

sourceSets {
intTest {
java.srcDir file('src/integrationTest/java')
resources.srcDir file('src/integrationTest/resources') // to add the resources
}
}

最佳答案

您可以尝试以下两个选项之一,看看其中一些是否适合您:

a)以这种方式声明的自定义sourceSets:

sourceSets {
intTest {
java {
srcDirs = ['src/integrationTest/java']
}
resources {
srcDirs = ['src/integrationTest/resources']
}
compileClasspath += sourceSets.main.output + sourceSets.main.compileClasspath + sourceSets.test.compileClasspath
runtimeClasspath += sourceSets.main.output + sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath
}
}


在这种情况下,您将以与测试依赖项相同的方式声明集成测试的依赖项。像这样:

testImplementation 'org.hibernate:hibernate:5.3.7.FINAL'


b)必须在自定义intTestImplementation之后声明sourceSets:

sourceSets {
intTest {
java {
srcDirs = ['src/integrationTest/java']
}
resources {
srcDirs = ['src/integrationTest/resources']
}
}
}
dependencies {
intTestImplementation 'org.hibernate:hibernate:5.3.7.FINAL'
}

关于gradle - 在类型为DefaultDependencyHandler的对象上找不到参数[org.hibernate:hibernate:5.3.7.FINAL]的方法intTestImplementation(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53531413/

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