如何从命令行使用 Eclipse 嵌入式 Maven 安装?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33414625/
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 use Eclipse embedded Maven installation from the command line?
提问by AndreaNobili
I am using STS (the Eclipse version for Spring) and it use the Maven plugin. It works fine but this Maven version is embedded into Eclipse.
我正在使用 STS(Spring 的 Eclipse 版本),它使用 Maven 插件。它工作正常,但此 Maven 版本已嵌入到 Eclipse 中。
Now I have to use it from the shell (the DOS prompt). If I try to perfrom thje mvn cleanstatment I obtain this error message:
现在我必须从 shell(DOS 提示符)使用它。如果我尝试执行 thje mvn cleanstatment,我会收到以下错误消息:
C:\Users\Andrea\Documents\workspaces\Real-Time\ud381\lesson1\stage1>mvn
"mvn" non è riconosciuto come comando interno o esterno,
un programma eseguibile o un file batch.
This is in Italian languange and it simply say that it can't find an internal or external mvncommand.
这是在意大利语语言中,它只是说它找不到内部或外部mvn命令。
So I think that I have to add it to the PATHenvironment Windows variable so I will can use it inside the command prompt.
所以我认为我必须将它添加到PATH环境 Windows 变量中,以便我可以在命令提示符中使用它。
The problem is that I can't find where is this embedded Maven installation.
问题是我找不到这个嵌入式 Maven 安装在哪里。
Where can I find it?
我在哪里可以找到它?
回答by Rüdiger Herrmann
To my knowledge, the Maven runtime that is embedded in m2(the plug-in that provides Maven support in Eclipse) is not suited to be used outside the IDE.
据我所知,嵌入在m2(在 Eclipse 中提供 Maven 支持的插件)中的 Maven 运行时不适合在 IDE 之外使用。
You will have to install regularMaven (available from https://maven.apache.org/download.cgi) to be able to use it from the command line. From my experience, using both in parallel works well.
您必须安装常规Maven(可从https://maven.apache.org/download.cgi 获得)才能从命令行使用它。根据我的经验,同时使用两者效果很好。
Alternatively, you can use Maven wrapperin your project - thus avoiding the need to install Maven for you and your team mates.
或者,您可以在您的项目中使用Maven 包装器- 从而避免需要为您和您的团队成员安装 Maven。
回答by juan san juan
It is possible to use Embedded Maven (at least in Windows)
可以使用嵌入式 Maven(至少在 Windows 中)
Add de installation-path\bin in variable PATH
在变量 PATH 中添加 de installation-path\bin
Define M2_HOME=installation-path
定义 M2_HOME=安装路径
Define JAVA_HOME
定义 JAVA_HOME
Installation path could be something like
安装路径可能类似于
C:\Users\juans.m2\wrapper\dists\apache-maven-3.6.3-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-3.6.3\bin
C:\Users\juans.m2\wrapper\dists\apache-maven-3.6.3-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-3.6.3\bin
Note: juans is the user
注:juans是用户
回答by Tushar Kshirsagar
On my local system, i installed maven in regular manner and also i changed settings in eclipse maven to refer the locally installed maven, in preferences setting you can do this, thus both the maven will utilise the same binaries and will run from local and from eclipse as well.
在我的本地系统上,我以常规方式安装了 maven,并且我还更改了 eclipse maven 中的设置以引用本地安装的 maven,在首选项设置中,您可以执行此操作,因此 maven 将使用相同的二进制文件,并将从本地和从蚀也是如此。