Maven如何依赖同名包

在利用maven管理依赖包时,如果出现依赖的包同名,可以采用下面的方式避免打包时同名包的冲突:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>com.xiaomi.misearch</groupId>
                        <artifactId>common</artifactId>
                        <version>0.0.1-SNAPSHOT</version>
                        <type>jar</type>
                        <outputDirectory>${project.basedir}/release/library</outputDirectory>
                        <destFileName>misearch-common-0.0.1-SNAPSHOT.jar</destFileName>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
        <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.basedir}/release/library</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>


你可能感兴趣的:(maven)