簡體   English   中英

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

[英]Is it required to specify Maven Surefire Plugin in pom.xml?

為什么這個 pom.xml 可以在沒有指定 maven surefire 插件的情況下運行mvn test

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

plugin放在pom.xml和不放有什么區別?

如果您沒有在 pom 中指定 maven-surefire-plugin,您的構建將采用 Maven 中指定的版本,請參閱https://maven.apache.org/ref/3.6.3/maven-core/default -bindings.html這些版本有一段時間沒有更新,以確保 Maven 的升級不會因為不同的插件版本而影響您的構建。 這些版本很可能會更新為下一個主要版本 Maven。因此這完全取決於您的項目的生命周期以及它是否是私有項目。 如果它的生命周期很長,最好將這些插件鎖定到特定版本,這樣你就不會依賴任何人用來構建項目的 Maven 版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM