Skip to content
欢迎扫码关注公众号

为什么默认排除 junit-vintage-engine?

使用 Spring Initializr 创建 Spring Boot 项目时,默认是包含 spring-boot-starter-test 包的。

如果选择 spring-boot-starter-parent 2.3.10 版时,会发现其依赖的写法如下:

xml
<!-- Test -->
<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>
    </exclusions>
</dependency>

之所以自动排除 junit-vintage-engine 是因为 spring-boot-starter-test2.2.x2.3.x 版本中还包含另外一个测试引擎 junit-jupiter-engine

junit-vintage-engine:用于 Junit-4 测试
junit-jupiter-engine:用于 Junit-5 测试

JUnit Jupiter is the combination of the new programming model and extension model for writing tests and extensions in JUnit 5. The Jupiter sub-project provides a TestEngine for running Jupiter based tests on the platform.

JUnit Vintage provides a TestEngine for running JUnit 3 and JUnit 4 based tests on the platform.

如果选择 spring-boot-starter-parent 2.4.5 版,则可以发现默认已经不包含这段 exclusions 配置了。

xml
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

原因在于 spring-boot-starter-test 2.4.x 版本中,已经不再包含 junit-vintage-engine 这个依赖项了。

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.