Home >Java >javaTutorial >How to Copy Maven Dependencies to target/lib After `mvn clean install`?

How to Copy Maven Dependencies to target/lib After `mvn clean install`?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-09 20:59:02453browse

How to Copy Maven Dependencies to target/lib After `mvn clean install`?

Copying Maven Dependencies to target/lib

Question:

After executing mvn clean install, the target folder only includes the project's JAR, without any runtime dependencies. How can I have these dependencies copied into the target/lib folder?

Answer:

To copy dependencies to target/lib, you can use the following Maven configuration:

<project>
  ...
  <profiles>
    <profile>
      <id>qa</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <phase>install</phase>
                <goals>
                  <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/lib</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

By adding this configuration, the maven-dependency-plugin will copy the JAR dependencies during the install phase, placing them in the specified outputDirectory.

The above is the detailed content of How to Copy Maven Dependencies to target/lib After `mvn clean install`?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn