我正在尝试使用Spring框架为我的第一个java项目编写一个junit测试。我在网上搜索了如何包含依赖项以便使用它,但一直遇到以下警告:
无法解析符号“SpringRunner”
在intelliJ的想法中。所以少了什么?这是我对gradle的依赖文件。
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")
}发布于 2018-03-13 03:38:08
尝试添加org.springframework.test.context.junit4.SpringRunner;
https://stackoverflow.com/questions/43339522
复制相似问题