如何告诉 M2Eclipse 将 jar 文件安装为 maven 依赖项 [英] How to tell M2Eclipse to install jar file as a maven dependency
问题描述
我想将 jpoller.jar
添加为 maven 依赖项,因此我编辑了我的 pom.xml 文件以包含它:
I want to add jpoller.jar
as a maven dependency, so I edited my pom.xml file to include it:
<dependency>
<groupId>org.sadun</groupId>
<artifactId>jpoller</artifactId>
<version>1.5.2</version>
</dependency>
现在,正如预期的那样,当我从命令行编译时出现错误,因为 jpoller
不在我在 pom 中列出的任何存储库中,我也找不到它.虽然我可以为它创建一个存储库,但我现在不想这样做.因此,我收到以下错误:
Now, as expected, when I compile from the command line I get an error because jpoller
isn't in any of the repositories I have listed in my pom, nor could I find one for it. Although I could create a repository for it, I'd rather not at this point. Thus, I get the following error:
[INFO] 无法解析工件.
[INFO] Failed to resolve artifact.
缺少:---------- 1) org.sadun:jpoller:jar:1.5.2
Missing: ---------- 1) org.sadun:jpoller:jar:1.5.2
尝试手动下载文件来自项目网站.
Try downloading the file manually from the project website.
然后,使用以下命令安装它:mvn install:install-file -DgroupId=org.sadun -DartifactId=jpoller -Dversion=1.5.2 -Dpackaging=jar -Dfile=/path/to/file
Then, install it using the command: mvn install:install-file -DgroupId=org.sadun -DartifactId=jpoller -Dversion=1.5.2 -Dpackaging=jar -Dfile=/path/to/file
如何在没有 maven CLI 的机器上通过 M2Eclipse 插件执行此操作?
How can I do this from the M2Eclipse plugin on machines where the maven CLI isn't available?
推荐答案
如何在没有 maven CLI 的机器上通过 M2Eclipse 插件执行此操作?
How can I do this from the M2Eclipse plugin on machines where the maven CLI isn't available?
好吧,只需从 Eclipse 中完成即可.首先,获取 jpoller jar 并将其保存在文件系统的某个位置.然后,在 Eclipse 中,从顶部栏中,Run > Run Configurations... 然后右键单击 Maven Build 并配置New_configuration 全新创建:
Well, simply do it from Eclipse. First, get that jpoller jar and save it somewhere on your file system. Then, in Eclipse, from the top bar, Run > Run Configurations... then right-click on Maven Build and configure the New_configuration freshly created:
- 选择任意基本目录
- 用
install:install-file
填写 Goals - 为每个必需参数添加参数,不带
-D
前缀(例如file
作为Parameter name
和/path/to/file
作为groupId
、artifactId
、packaging
和version 的 Value 等
).
- Select an arbitrary Base directory
- Fill the Goals with
install:install-file
- Add parameters for each required parameters, without the
-D
prefix (e.g.file
asParameter name
and/path/to/file
as Value and so on forgroupId
,artifactId
,packaging
andversion
).
并运行此配置.或者...只需安装 Maven.
And run this configuration. Or... just install Maven.
这篇关于如何告诉 M2Eclipse 将 jar 文件安装为 maven 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!