简体   繁体   English

Maven:Java jar依赖项未复制

[英]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. 我试图将所有依赖项复制到lib文件夹中以创建可执行jar。

I run mvn package and I see BUILD SUCCESS . 我运行mvn package ,看到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. 但是我看不到应该有依赖关系的任何目标文件夹lib ,并且没有创建文件Nespresso12345.jar。 I would like to know why. 我想知道为什么。

The pom.xml: 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. 使用Maven Shade插件创建可执行的JAR。 It works great. 效果很好。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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