I am trying to do a simple maven build with IntelliJ IDEA 10.5.1 on OS X Lion and am getting the following error:
Error running my-app [package]: No valid Maven installation found. Either set the home directory in the configuration dialog or set the M2_HOME environment variable on your system.
I have set M2_HOME to the following, but I am still having issues. And yes, I did restart IntelliJ.
$ echo $M2_HOME
/usr/share/maven
I then manually entered the path to maven in IntelliJ's Maven Settings for the project. This is not something that I want to do for every project, so is there something I am missing with how to get IntelliJ know where my maven home is?
In case you don't want to use the M2_HOME and want to direct the IntelliJ to the maven installation you can simply set it by:
A better way is to have a symlink e.g. 'latest' for the latest version and point your IntelliJ to use that for consistency, given latest points to the latest version of maven installed on your box.
type in Terminal:
then get following result:
here in second line we have:
type this path into field on configuration dialog. That's all to fix!
If
M2_HOME
is configured to point to the Maven home directory then:File -> Settings
Maven
Runner
Insert in the field
VM Options
the following string:Click
Apply
andOK
Another option is to add the M2_HOME variable at:
IntelliJ IDEA=>Preferences=>IDE Settings=>Path Variables
After a restart of IntelliJ,
IntelliJ IDEA=>Preferences=>Project Settings=>Maven=>Maven home directory
should be set to your M2_HOME variable.Got to this answer ? probably the answers above are to long ...
just type in :
and restart your mac (thats it!)
restarting is annoying ? just use the command :
and restart IntelliJ IDEA
If you are having this problem with a homebrew installation of maven 3 on the OSX 10.9.4 then check out this blog post.