M2_HOME在OSX 10.10.1 Yosemite上的IntelliJ中不起作用

时间:2014-12-17 15:42:21

标签: macos maven intellij-idea environment-variables osx-yosemite

我试过了:

echo $M2_HOME
/usr/local/apache-maven-3.2.3

似乎设置了M2_HOME

文件 /etc/launchd.conf 如下所示:

setenv $M2_HOME /usr/local/apache-maven-3.2.3

我已经重新启动了Mac,但仍然无效...

任何想法?

2 个答案:

答案 0 :(得分:0)

结帐:

"文件 /etc/launchd.conf 如下所示:"

改变:

setenv $M2_HOME /usr/local/apache-maven-3.2.3

setenv M2_HOME /usr/local/apache-maven-3.2.3

答案 1 :(得分:0)

创建新文件/Library/LaunchDaemons/setenv.M2_HOME.plist:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
      <plist version="1.0">
      <dict>
      <key>Label</key>
      <string>setenv.BAR</string>
      <key>ProgramArguments</key>
      <array>
        <string>/bin/launchctl</string>
        <string>setenv</string>
        <string>M2_HOME</string>
        <string>/opt/local/share/java/apache-maven-3.1.1</string>
      </array>
      <key>RunAtLoad</key>
      <true/>
      <key>ServiceIPC</key>
      <false/>
    </dict>
    </plist>

然后重新启动计算机,或执行

launchctl load -w /Library/LaunchDaemons/setenv.M2_HOME.plist

重新启动IDEA,它会选择MAVEN_HOME。在Yosemite 10.10.3上进行了测试。

来源:http://lajosd.blogspot.be/2015/06/place-following-content-enhance-it-to.html