gradle testCompile不解析依赖项

时间:2016-06-01 14:48:43

标签: java gradle junit

我的小gradle项目如下:

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

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

jar {
    baseName = 'web'
    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-actuator-docs')
    compile('org.springframework.boot:spring-boot-starter-amqp')
    compile('org.springframework.boot:spring-boot-starter-cache')
    compile('org.springframework.cloud:spring-cloud-starter-oauth2:1.1.0.RELEASE')
    compile('org.springframework.boot:spring-boot-devtools')
    compile('org.springframework.boot:spring-boot-starter-mail')
    compile('org.springframework.boot:spring-boot-starter-security')
    compile('org.springframework.boot:spring-boot-starter-social-facebook')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-websocket')

    compile('org.activiti:activiti-spring-boot-starter-basic')

    compile('org.springframework.boot:spring-boot-starter-data-mongodb')
    compile('org.activiti:activiti-spring-boot-starter-basic:5.19.0')

    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    runtime('mysql:mysql-connector-java')

    testCompile('junit:junit:4.12') 
    testCompile("org.springframework.boot:spring-boot-starter-test:1.3.5.RELEASE")
    testCompile('org.springframework:spring-test')
}

在完整构建期间,我遇到以下错误:

:compileJava
:processResources UP-TO-DATE
:classes
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava
D:\Max\java\agreit\web\src\test\java\com\agreit\WebApplicationTests.java:5: error: package org.springframework.boot.test.context does not exist
import org.springframework.boot.test.context.SpringBootTest;
                                            ^
D:\Max\java\agreit\web\src\test\java\com\agreit\WebApplicationTests.java:6: error: cannot find symbol
import org.springframework.test.context.junit4.SpringRunner;
                                              ^
  symbol:   class SpringRunner
  location: package org.springframework.test.context.junit4
D:\Max\java\agreit\web\src\test\java\com\agreit\WebApplicationTests.java:10: error: cannot find symbol
@SpringBootTest
 ^
  symbol: class SpringBootTest
D:\Max\java\agreit\web\src\test\java\com\agreit\WebApplicationTests.java:9: error: cannot find symbol
@RunWith(SpringRunner.class)
         ^
  symbol: class SpringRunner
4 errors
:compileTestJava FAILED

.gradle缓存中的这个奇怪我可以看到spring-boot-starter-test-1.3.5.RELEASE.jar - 但是这个文件不包含任何类。

0 个答案:

没有答案