Maven不希望您这样做,因为运行时的行为是不确定的。
如果你确实有充分的理由这样做,为了避免这个问题,你需要将依赖关系指定为
artifactItems
在依赖插件中。以下配置将把jar的两个版本复制到target/output,如果依赖插件在程序集插件之前执行,则可以通过指定
fileSet
指向目标/输出目录:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.7.0</version>
<type>jar</type>
<overWrite>false</overWrite>
</artifactItem>
<artifactItem>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.0</version>
<type>jar</type>
<overWrite>false</overWrite>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/output</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>