Java 如何在嵌入 Eclipse 的 Maven 存储库中安装 jars?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4323981/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install jars in maven repository which is eclipse embedded?
提问by Dinesh
My objective is to install a jar file in a Maven repository. This postexplains how to do an install with MVN.
我的目标是在 Maven 存储库中安装一个 jar 文件。这篇文章解释了如何使用 MVN 进行安装。
But but since I have Maven embedded in Eclipse, I don't know where to run the following command:
但是由于我在 Eclipse 中嵌入了 Maven,我不知道在哪里运行以下命令:
mvn install:install-file -Dfile=C:\lib\rest\WadlGenerator.jar \
-DgroupId=foo.in.shop.rest.wadl \
-DartifactId=WadlGenerator \
-Dversion=1.0 \
-Dpackaging=jar \
-DlocalRepositoryPath=C:\maven\repositories\internal
In short: How can I identify the Maven installation directory for Eclipse-embedded Maven?
简而言之:如何识别 Eclipse 嵌入式 Maven 的 Maven 安装目录?
采纳答案by darwin
From eclipse you can do:
从日食你可以做到:
Run -> Run Configurations -> Maven Build (double click)
运行 -> 运行配置 -> Maven 构建(双击)
Your goal is install:install-file
你的目标是 install:install-file
And also you should fill parameters' keys and values
而且你应该填写参数的键和值
P. S. But I think that it is more better to have external maven installation in system
PS但我认为在系统中安装外部maven更好
回答by Goibniu
The default location for the maven repository would be ~/.m2/repository.
maven 存储库的默认位置是 ~/.m2/repository。
Unless you changed this in the preferences of your eclipse plugin, then you should go with that. Replace the ~/ with whatever is appropriate for your home dir on your OS.
除非您在 eclipse 插件的首选项中更改了此设置,否则您应该使用它。将 ~/ 替换为适合您操作系统上的主目录的任何内容。
Edit: Updating based on the comments: There's an online book available for the m2eclipse plugin, and it would appear that you can run goals from the m2eclipse plugin - see the section here: m2eclipse Goals
编辑:根据评论更新:有一本可用于 m2eclipse 插件的在线书籍,看来您可以从 m2eclipse 插件运行目标 - 请参阅此处的部分:m2eclipse 目标
I presume there is a wizard of some sort when you click on the goal - I don't have m2eclipse installed here.
我认为当您单击目标时有某种向导 - 我这里没有安装 m2eclipse。
Edit2: actually looking at the other answer, this has been answered already :)
Edit2:实际上在看另一个答案,这已经回答了:)
回答by user281806
If you have M2Eclipse installed, and you have a Maven pom building the jar, use
如果您安装了 M2Eclipse,并且您有一个构建 jar 的 Maven pom,请使用
Run -> Run As... -> Maven Install
运行 -> 运行方式... -> Maven 安装
from the Eclipse menu to do the equivalient of
mvn install
从 Eclipse 菜单中做等效的
mvn install
回答by Divya
Or you can simply do: 1. Run 2. Maven Build.. 3. Copy the whole command in Goals i.e.
或者您可以简单地执行以下操作:1. 运行 2. Maven Build.. 3. 复制目标中的整个命令,即
install:install-file -Dfile=C:\lib\rest\WadlGenerator.jar \
-DgroupId=foo.in.shop.rest.wadl \
-DartifactId=WadlGenerator \
-Dversion=1.0 \
-Dpackaging=jar \
-DlocalRepositoryPath=C:\maven\repositories\internal
- Run
- 跑
This is much easier than filling keys and values :D
这比填充键和值容易得多:D