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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.