【问题标题】:How to add user defined library to maven dependencies in eclipse如何在 Eclipse 中将用户定义的库添加到 Maven 依赖项
【发布时间】:2015-10-28 05:45:23
【问题描述】:

如何在我的 Eclipse 中添加用户定义的库作为 maven 依赖项。我只是需要添加一堆罐子来创​​建一个 webapp。所以我刚刚创建了一个自定义库

【问题讨论】:

  • “库”是指 Eclipse 库(如“Maven Managed Dependencies”)吗?我认为您不想将其添加到 Maven 中。直接单独添加依赖即可。
  • 如果太多,您可以制作自己的 POM 来收集它们并依赖它。 stackoverflow.com/questions/23661856/…
  • 是的,我还期望/希望有一种简单的一次性方式让 Eclipse Maven 将 Eclipse 定义的用户库添加到其依赖项中:-(

标签: maven


【解决方案1】:

你可以直接在 pom 中添加依赖

<dependency>
    <groupId>sample</groupId>
    <artifactId>com.sample</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/src/main/resources/yourJar.jar</systemPath>
</dependency>

或者您可以将 jar 安装到您的 maven 存储库中

 mvn install:install-file
 -Dfile=<path-to-file>
 -DgroupId=<group-id>
 -DartifactId=<artifact-id>
 -Dversion=<version>
 -Dpackaging=<packaging>
 -DgeneratePom=true

 Where: <path-to-file>  the path to the file to load
    <group-id>      the group that the file should be registered under
    <artifact-id>   the artifact name for the file
    <version>       the version of the file
    <packaging>     the packaging of the file e.g. jar

然后将依赖项添加到您的 jar 中。

【讨论】:

  • 我有大约 200 个 jars 要添加.. 而不是添加每个依赖项是他们一次性添加所有内容的任何方式
  • 如果你无法避免这种情况,我会编写一些脚本来创建系统范围的依赖关系。这 200 个 jar 是不是您无法转换为 maven 项目的其他项目的自定义 jar?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-09-13
  • 2017-10-04
  • 2012-11-28
  • 1970-01-01
  • 2018-06-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多