Maven home (M2_HOME) not being picked up by IntelliJ IDEA

后端 未结 7 1840
时光取名叫无心
时光取名叫无心 2020-11-30 04:41

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

相关标签:
7条回答
  • 2020-11-30 04:58

    Mac OS apps cannot read bash environment variables. Look at this question Setting environment variables in OS X? to expose M2_HOME to all applications including IntelliJ. You do need to restart after doing this.

    0 讨论(0)
  • 2020-11-30 04:58

    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.

    0 讨论(0)
  • 2020-11-30 05:03

    Got to this answer ? probably the answers above are to long ...

    just type in :

    echo "setenv M2_HOME $M2_HOME" | sudo tee -a /etc/launchd.conf
    

    and restart your mac (thats it!)

    restarting is annoying ? just use the command :

    grep -E "^setenv" /etc/launchd.conf | xargs -t -L 1 launchctl
    

    and restart IntelliJ IDEA

    0 讨论(0)
  • 2020-11-30 05:04

    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:

    • goto File => Setting => Maven => Maven home directory
    • point to your maven build directory e.g. /usr/local/maven/apache-maven-3.0.4

    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.

    0 讨论(0)
  • 2020-11-30 05:05

    If M2_HOME is configured to point to the Maven home directory then:

    1. Go to File -> Settings
    2. Search for Maven
    3. Select Runner
    4. Insert in the field VM Options the following string:

      Dmaven.multiModuleProjectDirectory=$M2_HOME
      

    Click Apply and OK

    0 讨论(0)
  • 2020-11-30 05:10

    type in Terminal:

    $ mvn --version
    

    then get following result:

    Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 16:51:28+0300)
    Maven home: /opt/local/share/java/maven3
    Java version: 1.6.0_65, vendor: Apple Inc.
    Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    Default locale: ru_RU, platform encoding: MacCyrillic
    OS name: "mac os x", version: "10.9.4", arch: "x86_64", family: "mac"
    

    here in second line we have:

    Maven home: /opt/local/share/java/maven3
    

    type this path into field on configuration dialog. That's all to fix!

    0 讨论(0)
提交回复
热议问题