5

I use IntelliJ IDEA and write Spring project.

I added dependency

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

and more related to Spring Boot. I cannot import SpringApplicationContextLoader using:

import org.springframework.boot.test.SpringApplicationContextLoader

But I see many projects on GitHub which use this class.

How can I check current package of this class?

user
  • 4,410
  • 16
  • 57
  • 83

3 Answers3

14

According to javadoc of SpringApplicatioNContextLoader a.4.x it was deprecated in favor of @SpringBootTest or SpringBootContextLoader if absolutely necessary.

TuGordoBello
  • 4,350
  • 9
  • 52
  • 78
Sebastian
  • 877
  • 1
  • 9
  • 20
2

Solution provided by Yoav Gur doesn't work for the latest spring-boot (1.5.2.RELEASE).

In my case I was looking for a solution to activate a spring profile for my cucumber tests. And I too found a lot of solutions which import this SpringApplicationContextLoader.class. There is a class SpringBootContextLoader which might substitute for this, but I found another solution for my issues so didn't use it.

In case you're interested, you can find it here: How to activate spring boot profile with cucumber

Community
  • 1
  • 1
BitfulByte
  • 4,117
  • 1
  • 30
  • 40
  • I have found [this](https://github.com/karlbennett/spring-boot-cucumber-example) example where `SpringApplicationContextLoader` is used. Version is `1.2.4`. In later version (`1.5.x` and above) of spring-boot this class does not exists. I have to find another solution. – AndrasCsanyi Jun 20 '17 at 06:46
1

Try adding the following dependency to your pom:

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot</artifactId>
   <version>1.1.1.RELEASE</version>
</dependency> 

See: https://1maven.com/idartifact/org.springframework.boot:spring-boot:1.1.1.RELEASE

Yoav Gur
  • 1,366
  • 9
  • 15