Java 当我们使用多个概要文件时,artifactItem的版本是否默认为dependencies或DependencyManager中的版本?

Java 当我们使用多个概要文件时,artifactItem的版本是否默认为dependencies或DependencyManager中的版本?,java,maven,pom.xml,maven-profiles,Java,Maven,Pom.xml,Maven Profiles,我和maven一起工作 如本链接中所示:第二种情况下,如果工件作为依赖项列出,我们可以删除当前的标记。因为artifactItem的版本将默认为依赖项的版本 但使用概要文件时并非如此 我使用了两个配置文件,其中添加了依赖项。我的pom是这样的: <profile> <id>buildDependency</id> <activation> <activeByDefault>true

我和maven一起工作

如本链接中所示:第二种情况下,如果工件作为依赖项列出,我们可以删除当前的标记。因为artifactItem的版本将默认为依赖项的版本

但使用概要文件时并非如此

我使用了两个配置文件,其中添加了依赖项。我的pom是这样的:

<profile>
        <id>buildDependency</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <property>
                <name>maven.dependency</name>
                <value>true</value>
            </property>
        </activation>
        <dependencies>
            <dependency>
                <groupId>com.marshy</groupId>
                <artifactId>marshy1</artifactId>
                <version>1.1.0.5</version>
            </dependency>
现在,如果我将标记从认为它将从这里获取值的想法中移除,它将抛出错误声明无法收集的依赖项


我如何才能使此功能适用于概要文件?

我编辑了该示例,以在概要文件依赖项标记中指定junit依赖项。请参见此示例pom.xml。我没有遇到任何问题,这样做,所以可能有一个不同的问题,在你的pom,你只张贴了一部分

<project>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>build-dependency-example</artifactId>
    <groupId>org.example</groupId>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>junit</groupId>
                                    <artifactId>junit</artifactId>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
                                    <destFileName>optional-new-name.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/wars</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>buildDependency</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property>
                    <name>maven.dependency</name>
                    <value>true</value>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>3.8.1</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

</project>