【问题标题】:Eclipse Indigo doesn't include dependencies in jar folderEclipse Indigo 不包含 jar 文件夹中的依赖项
【发布时间】:2012-03-02 15:31:29
【问题描述】:

我正在使用 maven 和外部 jar 作为其他项目的输出。什么时候 我构建项目创建一个jar,不添加依赖项。我想添加依赖项。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>Generic.Demo</groupId>
      <artifactId>Generic.Demo</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <dependencies>
        <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-java</artifactId>
          <version>2.18.0</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.4</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.4</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.jexcelapi</groupId>
            <artifactId>jxl</artifactId>
            <version>2.6.12</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>11.0.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
      </dependencies>
      <dependencyManagement>
        <dependencies>
        </dependencies>
      </dependencyManagement>
      <modules></modules>
    </project>

这就是我的 pom.xml 文件的样子。没有要添加的构建/插件部分

请帮忙。

谢谢。

【问题讨论】:

  • 然后添加构建/插件部分。
  • 在提出任何此类问题之前,您需要先阅读一下 Maven。从sonatype.com/Support/Books 的免费书籍开始。通过示例查看 Maven。
  • 嗨@GuillaumePolet.. 谢谢

标签: java eclipse maven dependencies


【解决方案1】:

使用带有内置描述符jar-with-dependencies的maven程序集插件

在您的 pom.xml 中,将以下插件添加到您的构建/插件部分:

 <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.3</version>
    <configuration>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
    <executions>
  <execution>
    <id>build-package</id>
    <phase>package</phase>
    <goals>
      <goal>single</goal>
    </goals>
  </execution>
</executions>
 </plugin>

查看他们的网站了解所有详细信息。

【讨论】:

  • 感谢 Guillaume Polet 的回复。你能解释一下在哪里使用以及如何使用该描述符。
  • 嗨@Guillaume Polet。我按照你的解释试过了,但结果还是一样。
  • 您是否将目标绑定到一个阶段?我刚刚编辑了我的答案并添加了一个示例。然后运行mvn package,你应该得到你想要的
猜你喜欢
  • 2013-06-30
  • 2013-03-04
  • 2019-06-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-30
相关资源
最近更新 更多