Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve @SpringBootTest with a maven dependency with scope test

I added this repository to pom.xml, but IntelliJ fails to resolve org.springframework.boot.test:

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

enter image description here

However, after adding the library to classpath, it happens to work:

enter image description here enter image description here enter image description here

What's so special about this repository that I should add it manually?

EDIT:

<scope></scope> was causing this problem. I had no idea of what it actually does, and it made IntelliJ ignore my main directory.

like image 561
b1sub Avatar asked Dec 11 '25 19:12

b1sub


2 Answers

Deleted it manually from the local maven repository. If it still not working. Add the older version to pom.xml. Hope it work

like image 93
Do Thanh Dat Avatar answered Dec 14 '25 11:12

Do Thanh Dat


After adding the dependency to the pom.xml do a MAVEN REIMPORT. If it doesn't solve, go to main menu and do invalidate cache/restart ide. Then you are good to go.

like image 23
Chiran K. Avatar answered Dec 14 '25 09:12

Chiran K.