Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在没有版本标记的情况下定义maven依赖关系?_Maven_Dependencies_Pom.xml - Fatal编程技术网

如何在没有版本标记的情况下定义maven依赖关系?

如何在没有版本标记的情况下定义maven依赖关系?,maven,dependencies,pom.xml,Maven,Dependencies,Pom.xml,我有一个pom,在pom中不定义依赖版本就可以工作,另一个没有依赖版本就不能工作 有效的方法是: <project> <parent> <artifactId>artifact-parent</artifactId> <groupId>group-parent</groupId> <version>1.0-SNAPSHOT</version>

我有一个pom,在pom中不定义依赖版本就可以工作,另一个没有依赖版本就不能工作

有效的方法是:

<project>
    <parent>
        <artifactId>artifact-parent</artifactId>
        <groupId>group-parent</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>group-a</groupId>
            <artifactId>artifact-a</artifactId>
        </dependency>
        <dependency>
            <groupId>group-a</groupId>
            <artifactId>artifact-b</artifactId>
        </dependency>
    </dependencies>
</project>

:

三位一体代表了特定项目在时间上的坐标, 将其划分为该项目的依赖项


所以我的问题是第一个是如何工作的?

这里要注意的主要问题是:

<parent>
    <artifactId>artifact-parent</artifactId>
    <groupId>group-parent</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>

如果此值与默认值不同,则需要在父pom和子pom中明确定义它。

Ehm。。。是还是不是?
<parent>
    <artifactId>artifact-parent</artifactId>
    <groupId>group-parent</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>
<parent>
    <artifactId>artifact-parent</artifactId>
    <groupId>group-parent</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>
<project>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>group-a</groupId>
                <artifactId>artifact-a</artifactId>
                <version>1.0</version>
            </dependency>
            <dependency>
                <groupId>group-a</groupId>
                <artifactId>artifact-b</artifactId>
                <version>1.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>
<type>jar</type>
<classifier><!-- no value --></classifier>