Intellij idea Can';在intellij里面找不到斯波克
我是intellij和spock的新手 我正在使用gradle将spock测试添加到我的spring boot项目中。这是我的Intellij idea Can';在intellij里面找不到斯波克,intellij-idea,gradle,spock,Intellij Idea,Gradle,Spock,我是intellij和spock的新手 我正在使用gradle将spock测试添加到我的spring boot项目中。这是我的构建。gradle: buildscript { ext { springBootVersion = '1.4.0.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframew
构建。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'
}
}
所以我添加了一个spock测试,比如:
package com.heavyweightsoftware.theta.server.controller
/**
*
*/
class ThetaControllerTest extends spock.lang.Specification {
def "Theta"() {
}
}
但我无法在intellij环境中运行测试,因为它显示“无法解析符号‘spock’”
构建直接运行良好。有时,IJ可能在某些更改后不会更新项目类路径。对于
Maven POM文件
以及Gradle构建文件
,似乎都会发生这种情况。通常,通过强制从相应的工具窗口(,)中使用重新导入所有gradle/maven项目
按钮进行同步,可以轻松解决此问题:
添加依赖项对我来说完美无瑕。您是否已经尝试了“gradle工具”窗口中的“刷新所有gradle项目”按钮?如果您没有看到gradle工具窗口,请关闭并重新打开该项目。打开它时,使用build.gradle文件让IntelliJ知道它是一个gradle项目(它会询问您是否要重新导入;说“是”)。@Morfic“刷新所有radle项目”成功了。谢谢,我在网上找不到这个。你能帮我把答案贴出来吗?没问题。大多数时候IJ同步都会发生变化,但我在使用maven时遇到过几次这种情况,这通常是它重新工作的原因。只有几次我不得不强制缓存失效,因为其他任何东西都失败了