2016-08-22 98 views
1

我找不到哪個罐子將提供我的SpringRunner.classSpringRunner依賴類找不到

的依賴,我想我的集成測試升級到春季啓動1.4.0

+1

你是否聲明'spring-boot-starter-test'與版本的依賴關係?否則它應該自動使用正確的。 –

+0

是的,我現在解決了。我添加了spring-boot-starter-test依賴項,但不知何故下載的spring-test已損壞,因此依賴項沒有正確解決。感謝您的所有意見。 – Sagar

回答

4

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

使用以下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> 
1

手動嘗試添加此導入:

進口org.springframework.test.context.junit4.SpringRunner;