问题
A Java and Maven noob here:
Using OSX 10.8
And Installed Maven with HomeBrew
1- If I say which mvn
I will get this: /usr/local/bin/mvn
2- If I say echo $MAVEN_HOME
I will get nothing back.
3- If I go to my Maven Installation on EClipse it will look like this:

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.

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?
回答1:
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.
Intellij IDEA will use M2_HOME to find the Maven installation. Edit or create /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.
来源:https://stackoverflow.com/questions/15709845/ensuring-maven-home-is-set-correctly