SpringRunner依赖类无法定位

时间:2016-08-22 08:05:04

标签: java spring spring-boot

我无法找到哪个jar会为我提供(define (compare-multiple comp-func) (lambda (first . rest) (foldl comp-func ;; our comparison function first ;; our initial value rest))) ;; the rest of our values ;; I want to make my own min function (define my-min (compare-multiple (lambda (a b) (if (< a b) a b))) ;; result is 1 (my-min 42 1 45)

的依赖关系

我正在尝试将我的集成测试升级到spring-boot 1.4.0

7 个答案:

答案 0 :(得分:5)

SpringRunner.java位于spring-test-4.3.2.RELEASE.jar文件中。

要在Maven或Gradle项目中使用它,您应该声明对org.springframework.boot:spring-boot-starter-test的依赖。

以下是org.springframework.boot:spring-boot-starter-test依赖的库:

+--- org.springframework.boot:spring-boot-starter-test: -> 1.4.0.RELEASE
|    +--- org.springframework.boot:spring-boot-test:1.4.0.RELEASE
|    |    \--- org.springframework.boot:spring-boot:1.4.0.RELEASE (*)
|    +--- org.springframework.boot:spring-boot-test-autoconfigure:1.4.0.RELEASE
|    |    +--- org.springframework.boot:spring-boot-test:1.4.0.RELEASE (*)
|    |    \--- org.springframework.boot:spring-boot-autoconfigure:1.4.0.RELEASE (*)
|    +--- com.jayway.jsonpath:json-path:2.2.0
|    |    +--- net.minidev:json-smart:2.2.1
|    |    |    \--- net.minidev:accessors-smart:1.1
|    |    |         \--- org.ow2.asm:asm:5.0.3
|    |    \--- org.slf4j:slf4j-api:1.7.16 -> 1.7.19
|    +--- junit:junit:4.12
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    +--- org.assertj:assertj-core:2.5.0 -> 2.4.1
|    +--- org.mockito:mockito-core:1.10.19
|    |    +--- org.hamcrest:hamcrest-core:1.1 -> 1.3
|    |    \--- org.objenesis:objenesis:2.1 -> 2.2
|    +--- org.hamcrest:hamcrest-core:1.3
|    +--- org.hamcrest:hamcrest-library:1.3
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    +--- org.skyscreamer:jsonassert:1.3.0
|    |    \--- org.json:json:20090211 -> 20140107
|    +--- org.springframework:spring-core:4.3.2.RELEASE
|    \--- org.springframework:spring-test:4.3.2.RELEASE
|         \--- org.springframework:spring-core:4.3.2.RELEASE

SpringRunner.java

答案 1 :(得分:1)

您可以在search.maven.org

中搜索课程

https://search.maven.org/#search|ga|1|fc%3A%22SpringRunner%22

答案 2 :(得分:1)

使用以下maven依赖项。

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath />
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

</dependencies>

答案 3 :(得分:1)

尝试手动添加此导入:

import org.springframework.test.context.junit4.SpringRunner;

答案 4 :(得分:1)

如果其他人阅读并遇到同样的问题,我通过从 spring-boot-starter-test 中删除 <scope>test<scope> 来解决依赖关系。实际上,该参数表明依赖项不在编译时使用,而仅在测试期间使用;然而,这不是我们的情况。
这是来自 pom 的新片段:

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.1.4.RELEASE</version>

附言我另外匹配了 spring-boot-starter-testspring-boot-starter-parent 的版本。

答案 5 :(得分:0)

下载Spring-test jar并通过添加外部jar手动将其添加到构建路径。它为我解决了所有问题。

::从这里下载jar: https://mvnrepository.com/artifact/org.springframework/spring-test/2.5

答案 6 :(得分:0)

将spring-boot-starter-parent升级到2.0.1.RELEASE

    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->