Maven 主页 (M2_HOME) 没有被 IntelliJ IDEA 接收 [英] Maven home (M2_HOME) not being picked up by IntelliJ IDEA
问题描述
我正在尝试在 OS X Lion 上使用 IntelliJ IDEA 10.5.1 进行简单的 maven 构建,但出现以下错误:
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:
运行 my-app [包] 时出错:找不到有效的 Maven 安装.在配置对话框中设置主目录或设置系统上的 M2_HOME 环境变量.
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.
我已将 M2_HOME 设置为以下值,但仍有问题.是的,我确实重启了 IntelliJ.
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
然后我在项目的 IntelliJ 的 Maven 设置中手动输入了 Maven 的路径.这不是我想为每个项目做的事情,所以我是否缺少如何让 IntelliJ 知道我的 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?
推荐答案
Mac OS 应用程序无法读取 bash 环境变量.看这个问题 Setting environment variables in OS X? 暴露M2_HOME
到包括 IntelliJ 在内的所有应用程序.执行此操作后,您确实需要重新启动.
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.
这篇关于Maven 主页 (M2_HOME) 没有被 IntelliJ IDEA 接收的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!