是否需要在pom.xml中指定Maven Surefire插件?

莱斯特

为什么mvn test没有指定的maven surefire插件就可以运行此pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.lester</groupId>
    <artifactId>junit-basics</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>junit-basics</name>

    <properties>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>
        <junit.jupiter.version>5.4.0</junit.jupiter.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

将插件放入pom.xml和不放入插件有什么区别?

罗伯特·斯科特

如果您未在pom中指定maven-surefire-plugin,则您的构建将选择Maven中指定的版本,请参阅https://maven.apache.org/ref/3.6.3/maven-core/default -bindings.html这些版本已经有一段时间没有更新了,以确保Maven的升级不会因为插件版本不同而影响您的构建。这些版本很可能会在Maven的下一个主要版本中进行更新。因此,这全都取决于项目的生命周期以及是否为私有项目。如果使用寿命很长,最好将这些插件锁定到特定版本,因此您不必依赖任何人用来构建项目的Maven版本。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章