SpringBootTest annotation doesn't work in maven build command

Viewed 26

I add annotation SpringBootTest on my test class, it works very well in IDE(intellij), but when I run mvn test command, it seems SpringBootTest annotation doesn't work, because I didn't see spring context is initialized from logs and the auto-wired object is null. Does anyone know what might be wrong?

BTW, I use spring-boot 2.7.1

1 Answers

This is maven-surefire-plugin issue, spring boot 2.7.1 use junit5 while the maven-surefire-plugin I used doesn't support junit5. Upgrading maven-surefire-plugin can solve this problem

Related