无法解析符号';SpringRunner';对于java Spring junit
我正在尝试使用Spring框架为我的第一个java项目编写junit测试。我在网上搜索了如何包含依赖项以使用它,但不断遇到以下警告: 无法解析符号“SpringRunner” 在intelliJ思想中。那么缺少什么呢? 这是我对gradle的依赖文件无法解析符号';SpringRunner';对于java Spring junit,java,spring-mvc,Java,Spring Mvc,我正在尝试使用Spring框架为我的第一个java项目编写junit测试。我在网上搜索了如何包含依赖项以使用它,但不断遇到以下警告: 无法解析符号“SpringRunner” 在intelliJ思想中。那么缺少什么呢? 这是我对gradle的依赖文件 buildscript { repositories { mavenCentral() } dependencies { classpath("org.springframework.boot
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle- plugin:1.5.1.RELEASE")
classpath("org.springframework:spring-test:4.0.3.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
testCompile("org.springframework:spring-test:4.0.3.RELEASE")
compile('com.google.maps:google-maps-services:0.1.18')
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
compile("org.springframework.boot:spring-boot-starter-web")
testCompile('junit:junit:4.12')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile("org.springframework.security:spring-security-test")
}
尝试添加
org.springframework.test.context.junit4.SpringRunner代码>请,您可以添加您的测试类吗?我想您的问题是spring boot gradle-plugin
中的空格(请参见第6行)。尝试将其替换为spring boot gradle插件
。