如何将maven依赖项下载到特定文件夹

时间:2012-07-08 13:19:12

标签: maven maven-2 maven-3

我在pom.xml文件中有以下依赖项,

    <dependencies>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

我想将下载的jar文件保存到我指定的目录中。具体方法是什么?

1 个答案:

答案 0 :(得分:1)

在构建POM部分中尝试此操作:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.1</version>
    <executions>
        <execution>
            <id>copy</id>
            <phase>process-resources</phase>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>[your.dep.group.id]</groupId>
                        <artifactId>[your.dep.artifact.id]</artifactId>
                        <version>[your.dep.version]</version>
                        <type>jar</type>
                        <overWrite>true</overWrite>
                        <outputDirectory>[your.output.dir]</outputDirectory>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>