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
Release: 2024-11-09 20:59:02
Original
448 people have browsed it

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template