简体   繁体   English

maven安装文件“缺少工件”

[英]maven install-file “Missing artifact”

I want to reference a jar (ie vim25.jar, VMWare VSphere server management) in the POM of my project. 我想在项目的POM中引用一个jar(即vim25.jar,VMWare VSphere服务器管理)。 As this file is not referenced in MavenRepository I do the following steps: 由于在MavenRepository中未引用此文件,因此请执行以下步骤:

  • Download the file from VMWare site 从VMWare站点下载文件
  • Install the file using: 使用以下命令安装文件:

mvn install:install-file -Dfile=./vim25.jar -DgroupId=manuallyInstalledJars -DartifactId=vim25 -Dversion=2.5 -Dpackaging=jar mvn install:安装文件-Dfile =。/ vim25.jar -DgroupId = manuallyInstalledJars -DartifactId = vim25 -Dversion = 2.5 -Dpackaging = jar

Everyting works well and I can find the jar in myLocalRepo/manuallyInstalledJars/vim25/2.5/vim25-2.5.jar 一切正常,我可以在myLocalRepo / manuallyInstalledJars / vim25 / 2.5 / vim25-2.5.jar中找到该jar。

  • Beside the jar there is the POM, I open it and extract the dependency references: 在jar旁边有POM,我将其打开并提取依赖项引用:

[groupId]manuallyInstalledJars[/groupId] [groupId] manuallyInstalledJars [/ groupId]

[artifactId]vim25[/artifactId] [artifactId] vim25 [/ artifactId]

[version]2.5[/version] [版本] 2.5 [/版本]

("<" replaced by "[" because of the editor) (由于编辑器,“ <”替换为“ [”)

I enclose this with the [dependency] tag and put everything in the POM that uses the jar 我用[dependency]标签将其括起来,并将所有内容放入使用jar的POM中

  • In Eclipse I get an error (red mark in the text editor) with this comment: "Missing artifact manuallyInstalledJars:vim25:jar:2.5" 在Eclipse中,我收到一条带有以下注释的错误(文本编辑器中的红色标记):“手动缺少工件” InstalledJars:vim25:jar:2.5

Any idea ? 任何想法 ?

Perhaps just post the dependency xml so we can rule that out. 也许只是发布依赖项xml,以便我们可以排除这种情况。

In any case try this in Eclipse (assuming you have m2eclipse plugin installed) 无论如何,请在Eclipse中尝试此操作(假设您已安装m2eclipse插件)

Window-> Show View -> Maven Repositories 窗口->显示视图-> Maven存储库

Expand Local Repositories 扩展本地存储库

Right click Local Repository -> Rebuild Index. 右键单击本地存储库->重建索引。

This sometimes help refresh the maven repo in Eclipse when youve made external changes 进行外部更改后,有时这有助于刷新Eclipse中的Maven存储库

After the rebuild, check you can see the JAR in that local repository tree in the maven repositories view. 重建之后,检查您是否可以在maven存储库视图中的本地存储库树中看到JAR。 You can also confirm that Eclipse is looking at the same local repository as your external maven installation. 您还可以确认Eclipse在寻找与外部Maven安装相同的本地存储库。

If it's not, check the user settings in the eclipse preferences. 如果不是,请在Eclipse偏好设置中检查用户设置。

Window -> Preferences -> Maven -> User Settings 窗口->首选项-> Maven->用户设置

You can check it is referencing the correct maven settings xml file 您可以检查它是否引用了正确的Maven设置xml文件

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

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