Maven:未复制Java jar依赖项

时间:2015-07-24 13:52:22

标签: java maven

我有一个项目依赖于我工作区中的不同项目模块。我试图将所有依赖项复制到lib文件夹以创建可执行jar。

我运行mvn package,我看到BUILD SUCCESS

但我没有看到任何目标文件夹lib,其中应该存在依赖项,并且不会创建Nespresso12345.jar文件。我想知道原因。

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>

1 个答案:

答案 0 :(得分:0)

使用Maven Shade插件创建可执行JAR。它很棒。

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

相关问题