简体   繁体   中英

Maven: Java jar dependencies not copied

I have a project that depends on a different project-module in my workspace. I'm trying to copy all dependencies to a lib folder for creating an executable jar.

I run mvn package and I see BUILD SUCCESS .

But I don't see any destination folder lib in which there should be the dependencies and the file Nespresso12345.jar isn't created. I would like to know why.

The pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.4</version>
    <executions>
      <execution>
        <id>copy</id>
        <phase>package</phase>
        <goals>
          <goal>copy</goal>
        </goals>
        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>junit</groupId>
              <artifactId>junit</artifactId>
              <version>4.8.1</version>
              <type>jar</type>
              <overWrite>false</overWrite>
              <outputDirectory>${project.build.directory}/lib</outputDirectory>
              <destFileName>Nespresso12345.jar</destFileName>
            </artifactItem>
          </artifactItems>
          <outputDirectory>${project.build.directory}/lib2</outputDirectory>
          <overWriteReleases>false</overWriteReleases>
          <overWriteSnapshots>true</overWriteSnapshots>
        </configuration>
      </execution>
    </executions>
  </plugin>

Use the Maven Shade plugin to create your executable JAR. It works great.

http://maven.apache.org/plugins/maven-shade-plugin/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM