将maven项目的依赖项复制到特定文件夹

Bop*_*psi 7 dependencies maven

我想在特定文件夹中获取maven项目所需的所有jar.

我用过mvn dependency:copy-dependencies命令.

它为我提供了文件taget/dependeny夹中所需的jar文件.

虽然我可以使用move或copy coommand将这些jar复制到另一个目录,但有没有办法直接复制我选择的目录中的依赖项?

DB5*_*DB5 13

您需要使用该outputDirectory属性来定义要将jar复制到的所需位置.

以下是您要在POM中添加的配置示例:

<plugins>
...
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <id>copy-dependencies</id>
                <phase>package</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                    <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
                </configuration>
            </execution>
        </executions>
    </plugin>
    ...
</plugins>
Run Code Online (Sandbox Code Playgroud)

或者,您可以通过命令行直接传递此配置:

mvn -DoutputDirectory=alternativeLocation dependency:copy-dependencies 
Run Code Online (Sandbox Code Playgroud)