我使用IntelliJ IDEA编写Spring项目。
我添加了依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
与Spring Boot有关。 我无法使用:
导入SpringApplicationContextLoaderimport org.springframework.boot.test.SpringApplicationContextLoader
但是我在GitHub上看到很多使用这个类的项目。
如何查看此课程的当前包裹?
答案 0 :(得分:12)
根据SpringApplicatioNContextLoader a.4.x的javadoc,如果绝对必要,不推荐使用@SpringBootTest或SpringBootContextLoader。
答案 1 :(得分:2)
Yoav Gur提供的解决方案不适用于最新的spring-boot(1.5.2.RELEASE)。
在我的情况下,我正在寻找一种解决方案来激活我的黄瓜测试的弹簧配置文件。我也发现了许多导入SpringApplicationContextLoader.class的解决方案。 有一个类SpringBootContextLoader可以替代它,但我找到了另一个解决我的问题的解决方案,所以没有使用它。
如果您有兴趣,可以在此处找到: How to activate spring boot profile with cucumber
答案 2 :(得分:1)
尝试将以下依赖项添加到您的pom:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>1.1.1.RELEASE</version>
</dependency>
请参阅: https://1maven.com/idartifact/org.springframework.boot:spring-boot:1.1.1.RELEASE