简体   繁体   English

SpringBootTest 注解在 maven 构建命令中不起作用

[英]SpringBootTest annotation doesn't work in maven build command

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.我在我的测试 class 上添加注释 SpringBootTest,它在 IDE(intellij) 中运行良好,但是当我运行mvn test命令时,似乎 SpringBootTest 注释不起作用,因为我没有看到 spring 上下文是从日志初始化的自动接线的 object 是 null。 Does anyone know what might be wrong?有谁知道可能出了什么问题?

BTW, I use spring-boot 2.7.1顺便说一句,我使用 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.这是 maven-surefire-plugin 问题,spring 启动 2.7.1 使用 junit5 而我使用的 maven-surefire-plugin 不支持 junit5。 Upgrading maven-surefire-plugin can solve this problem升级 maven-surefire-plugin 可以解决这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM