SpringApplicationConfiguration无法解析为某种类型

时间:2017-08-10 05:12:44

标签: java spring maven junit

我正在尝试在我的spring启动应用程序上运行junit测试。这是我的pom.xml

<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
</dependency>


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

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

然后在测试类中我有以下代码:

import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.boot.test.SpringApplicationConfiguration;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SeleniumApplication.class)
public class DataExtractorTest {

}

不幸的是,在行

@SpringApplicationConfiguration(classes = SeleniumApplication.class)

抱怨

SpringApplicationConfiguration cannot be resolved to a type

甚至当我添加了

import org.springframework.boot.test.SpringApplicationConfiguration

抱怨

The import org.springframework.boot.test.SpringApplicationConfiguration cannot be resolved

我已经清理了我的项目,并多次更新了我的maven项目,甚至关闭了STS并再次尝试,但没有一个工作。

0 个答案:

没有答案