eclipse 确保 MAVEN_HOME 设置正确

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15709845/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 20:18:00  来源:igfitidea点击:

Ensuring MAVEN_HOME is set correctly

javaeclipsemavenintellij-ideamaven-3

提问by DarkNightFan

A Java and Maven noob here:

这里有一个 Java 和 Maven 菜鸟:

Using OSX 10.8

使用 OSX 10.8

And Installed Maven with HomeBrew

并用 HomeBrew 安装了 Maven

1- If I say which mvnI will get this: /usr/local/bin/mvn

1-如果我说which mvn我会得到这个:/usr/local/bin/mvn

2- If I say echo $MAVEN_HOMEI will get nothing back.

2-如果我说echo $MAVEN_HOME我什么也得不到。

3- If I go to my Maven Installation on EClipse it will look like this:

3- 如果我在 EClipse 上转到我的 Maven 安装,它将如下所示:

enter image description here

在此处输入图片说明

4- If I go to Maven settings in IntelliJ, it will look like this: So far I have been able to run Maven goals with IntelliJ.

4- 如果我转到 IntelliJ 中的 Maven 设置,它将如下所示: 到目前为止,我已经能够使用 IntelliJ 运行 Maven 目标。

enter image description here

在此处输入图片说明

Ok That's all I have. Can you please take a look and see what are the inconsistencies I am having and what things to fix to set this correctly everywhere?

好的,这就是我所拥有的。你能看看我有什么不一致之处,需要解决哪些问题才能在任何地方正确设置?

回答by timomeinen

Under Mac OS X you should setup your environment variables in /etc/launchd.conf. Variables loaded by launchd are available in your shell as well as in GUI applications like Intellij IDEA.

在 Mac OS X 下,您应该在/etc/launchd.conf. launchd 加载的变量在您的 shell 以及 GUI 应用程序(如 Intellij IDEA)中可用。

Intellij IDEA will use M2_HOME to find the Maven installation. Edit or create /etc/launchd.conf:

Intellij IDEA 将使用 M2_HOME 来查找 Maven 安装。编辑或创建/etc/launchd.conf

setenv M2_HOME /usr/share/maven

Unfortunately to see the effect, you have to reboot your machine. Another shortcoming is, that you cannot use spaces in the file. This means, you cannot set MAVEN_OPTS to more than one value.

不幸的是,要看到效果,您必须重新启动机器。另一个缺点是,您不能在文件中使用空格。这意味着,您不能将 MAVEN_OPTS 设置为多个 value