【问题标题】:Ho do I convert exclusion maven code to gradle我如何将排除 maven 代码转换为 gradle
【发布时间】:2021-01-28 20:40:32
【问题描述】:

我正在使用转换器将 maven 项目转换为 gradle。这是maven代码:

 <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>

这是转换器的作用:

testCompile "org.springframework.boot:spring-boot-starter-test:*"

我认为它做得很好。但是这个呢?

<exclusion>
                        <groupId>org.junit.vintage</groupId>
                        <artifactId>junit-vintage-engine</artifactId>
                    </exclusion>

是否可以省略它或项目中的smth会被更改?

还有一个代码:

<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <type>jar</type>
        </dependency>

如何将其转换为 gradle?标签类型的罐子让我很困惑。感谢您的建议。

【问题讨论】:

    标签: spring maven gradle


    【解决方案1】:

    第一个 sn-p 的等效 Gradle 排除项是:

    dependencies {
      testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude group: "org.junit.vintage", module: "junit-vintage-engine"
      }
    }
    

    根据您的测试编写方式,排除可能会或可能不会影响您。

    如果您有 JUnit 4 测试,那么您需要 JUnit Vintage 模块。所以省略排除。

    但是,如果您只有 JUnit 5 测试,那么您可能不需要任何 JUnit 4 (JUnit Vintage) 的东西。


    旁白:Spring Boot 2.2.x includes both JUnit 4 and 5。我相信从 2.3.x 开始,Spring Boot 团队开始排除 JUnit 4,如上所示,最终 removed JUnit 4 in 2.4.x

    【讨论】:

      猜你喜欢
      • 2020-04-30
      • 1970-01-01
      • 1970-01-01
      • 2015-08-12
      • 1970-01-01
      • 2014-01-18
      • 1970-01-01
      • 2018-06-19
      • 2015-12-13
      相关资源
      最近更新 更多