在intellij里面找不到spock

Tho*_*hom 2 intellij-idea gradle spock

我是intellij和spock的新手.

我正在使用gradle将spock测试添加到我的spring启动项目中.这是我的build.gradle:

buildscript {
    ext {
        springBootVersion = '1.4.0.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'

jar {
    baseName = 'theta-server'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile('org.spockframework:spock-core:1.0-groovy-2.4')
}


eclipse {
    classpath {
         containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
         containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
    }
}
Run Code Online (Sandbox Code Playgroud)

所以我添加了一个spock测试:

package com.heavyweightsoftware.theta.server.controller

/**
 * 
 */
class ThetaControllerTest extends spock.lang.Specification {
    def "Theta"() {

    }
}
Run Code Online (Sandbox Code Playgroud)

但我无法在intellij环境中运行测试,因为它说"无法解析符号'spock'"

构建运行正常.

Mor*_*fic 5

有时,IJ可能在一些更改后不更新项目类路径.似乎这既发生在两者上Maven POM files,也发生在Gradle build files.通常,通过Reimport all gradle/maven projects从适当的工具窗口(maven,gradle)强制与按钮同步,可以轻松解决这个问题:

摇篮

Maven的