gpt4 book ai didi

spring - spring-boot-test 与 spring-boot-starter-test 有什么区别?

转载 作者:行者123 更新时间:2023-12-03 16:06:35 24 4
gpt4 key购买 nike

我正在处理一个项目,我看到定义了这些依赖项:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>

但是我不明白为什么有 2 个 Artifact 用于 Spring Boot 测试,它们之间有什么区别?也许对于后者,我也在导入前者?

最佳答案

spring-boot-starter-test是一个聚合的“入门包”,用于经常一起用于在 Spring 应用程序中进行测试的库。

如最新版本引用 documentation 中所述, spring-boot-starter-test包含:

  • JUnit 5(包括与 JUnit 4 向后兼容的老式引擎)
  • Spring 测试和 Spring Boot 测试 - 这是 spring-boot-test依赖)
  • AssertJ、Hamcrest、Mockito、JSONassert 和 JsonPath。
  • 关于spring - spring-boot-test 与 spring-boot-starter-test 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61117933/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com