ARTICLE AD BOX
IntelliJ IDEA is not recognizing the @Testcontainers, @Container and MySQLContainer symbols, showing "Cannot resolve symbol 'Testcontainers'" even though the dependencies are correctly declared in pom.xml and mvn dependency:tree shows them being resolved successfully.
Environment:
IntelliJ IDEA (version: 21.0.9)
Java 25
Spring Boot 3.4.5
Windows 11
Maven (built-in from IntelliJ)
What mvn dependency:tree shows (dependencies ARE resolved):
[INFO] +- org.testcontainers:junit-jupiter:jar:1.20.5:test
[INFO] | \- org.testcontainers:testcontainers:jar:1.20.6:test
[INFO] +- org.testcontainers:mysql:jar:1.20.5:test
pom.xml:
<dependency> <groupId>org.testcontainers</groupId> <artifactId>junit-jupiter</artifactId> <version>1.20.5</version> <scope>test</scope> </dependency> <dependency> <groupId>org.testcontainers</groupId> <artifactId>mysql</artifactId> <version>1.20.5</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> import org.testcontainers.junit.jupiter.Testcontainers; // Cannot resolve import org.testcontainers.junit.jupiter.Container; // Cannot resolve import org.testcontainers.containers.MySQLContainer; // Cannot resolve @Testcontainers @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ArtistControllerIT { ... }What I already tried:
Maven -> Reload All Maven Projects File -> Invalidate Caches → Invalidate and Restart Deleted .idea folder and reopened the project Removed duplicate spring-boot-starter-test dependency (it was declared twice, once without scope test) mvn dependency:resolve in terminal — no errors
Please, help! I'm stuck on this since yesterday!!
