问题描述
我正在使用 BOM 开发一个非常简单的 Spring Boot 2.4.2 项目:
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.4.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
当运行 mvn clean verify
时,我得到这个:我们看到 Surefire 2.12.4 没有找到任何测试
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ api-testing ---
[INFO] Surefire report directory: C:\Users\vincent\IdeaProjects\api-testing\target\surefire-reports
------------------------------------------------------- T E S T S
-------------------------------------------------------
Results :
Tests run: 0,Failures: 0,Errors: 0,Skipped: 0
我不明白为什么..我尝试了几件事,即使不推荐,我也尝试通过在我的 pom 中添加它来覆盖版本:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
现在我的测试找到了!
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ api-testing ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running de.vincent.AssetreferentialServiceTest
我真的对 Spring Boot 的这种行为感到惊讶 - 我想我错过了一些东西......但是什么?
注意:我的测试是 Junit 5 测试,我的类路径中没有与 Junit 4 相关的 jar - 只有 Junit Jupiter 5.7.0 和 Junit 平台 1.7.0
谢谢
解决方法
非常感谢@M。 Deinum 在评论中指出问题。
当然,使用 Spring Boot 父 pom 有助于使用正确的插件版本!
# print(df_)
ind
3 2.3
3 4.4
3 3.3
Name: value,dtype: float64
BOM 只对依赖项有帮助,对构建插件没有帮助。