Why cant i import @WithMockUser to my test

Try fresh dependency. I just solved such issue with this one:

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

Add an import statement for the library:

import org.springframework.security.test.context.support.WithMockUser;

And declare a dependency in your pom:

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

Tags:

Spring Boot