错误:(56,0)原因:org.gradle.api.tasks.testing.Test\u无法转换为java.lang.Class
我有这个错误:(56,0)原因:org.gradle.api.tasks.testing.Test\u无法转换为java.lang.Class,java,groovy,intellij-idea,build,gradle,Java,Groovy,Intellij Idea,Build,Gradle,我有这个build.gradle apply plugin: 'java' sourceCompatibility = 1.8 version = '1.0' repositories { mavenCentral() } dependencies { // // configurations.all*.exclude(group: 'com.sun.jersey', module: 'jersey-bundle') // configurations.all*.exc
build.gradle
apply plugin: 'java'
sourceCompatibility = 1.8
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
//
// configurations.all*.exclude(group: 'com.sun.jersey', module: 'jersey-bundle')
// configurations.all*.exclude(group: 'com.fasterxml.jackson.core', module:'jackson-databind')
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
compile 'com.google.inject:guice:4.0-beta5'
compile 'com.sun.jersey:jersey-core:1.18.3'
compile 'com.sun.jersey:jersey-client:1.18.3'
//testCompile group: 'junit', name: 'junit', version: '4.11'
}
sourceSets {
main {
java {
srcDirs = ['src/main']
}
}
test {
java {
srcDirs = ['src/main']
}
}
}
test {
testLogging {
// Show that tests are run in the command-line output
events 'started', 'passed'
}
}
task testBaseLineGenerator(type: test) {
systemProperties['test.single'] = 'BaseLineGenerator'
}
task testTotalLatency(type: test) {
systemProperties['test.single'] = 'TotalLatencyTest'
}
一旦我添加了以下内容,就会出现Intellij错误:
task testBaseLineGenerator(type: test) {
systemProperties['test.single'] = 'BaseLineGenerator'
}
task testTotalLatency(type: test) {
systemProperties['test.single'] = 'TotalLatencyTest'
}
我得到了这个错误:
Error:(56, 0) Cause: org.gradle.api.tasks.testing.Test_Decorated cannot be cast to java.lang.Class
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
错误:(56,0)原因:org.gradle.api.tasks.testing.Test\u无法转换为java.lang.Class
此意外错误的可能原因包括:- Gradle的依赖项缓存可能已损坏(这有时在网络连接超时后发生。)
- 渐变生成进程(守护进程)的状态可能已损坏。停止所有Gradle守护进程可以解决此问题。
如果Gradle进程损坏,也可以尝试关闭IDE,然后关闭所有Java进程。
尝试了它建议的两个选项,但都没有用。我设法解决了我的问题: 我改为
任务testBaseLineGenerator(类型:Test){
Test
而不是Test
我设法解决了我的问题:
我改为任务testBaseLineGenerator(类型:Test){
测试
而不是测试
请使用问题上的编辑链接添加其他信息。回答后按钮应仅用于问题的完整答案。但是没有更多信息。您认为我应该添加什么?它解决了我的问题,然后您应该编辑此按钮,以提及进行此更改nge解决了您的问题并将其标记为acceptedI在自定义jar任务中遇到了类似的问题,问题是类型应该是“jar”而不是“jar”。请使用问题上的“编辑”链接添加其他信息。“发布答案”按钮应仅用于该问题的完整答案。但没有更多信息。您认为我应该添加什么?它解决了我的问题,然后您应该编辑此链接以提述进行此更改解决了您的问题并将其标记为acceptedI had在自定义jar任务中也存在类似的问题,问题是类型应该是“jar”而不是“jar”。