install maven on mac

十年热恋 提交于 2019-12-24 05:46:06

问题


i'm trying to install maven on my mac first i downloaded apache-maven-3.3.9 and then i entered this code on my bash:

export M2_HOME=$(/usr/local/apache-maven/apache-maven-3.3.9)

and

export PATH=${PATH}:/Users/sabrine/ant/bin:$JAVA_HOME/bin:$ANT_HOME/bin:$M2_HOME/bin:

but it doesn't work i got(i tried with mvn -v)

-bash: mvn: command not found

where is the problem? what should i do?


回答1:


Don't add $( ) around the paths, just use:

export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9

Followed by yours:

export PATH=${PATH}:/Users/sabrine/ant/bin:$JAVA_HOME/bin:$ANT_HOME/bin:$M2_HOME/bin:

The above assumes that your maven installation is in /usr/local/apache-maven/apache-maven-3.3.9, and ls -ld /usr/local/apache-maven/apache-maven-3.3.9 gives non-error output.




回答2:


Please follow below steps on terminal

Create bash profile (will be created under home folder and will be hidden file)

$ touch .bash_profile

Edit bash profile in editor and put next 2 commands in file, save file.

 export M2_HOME=/Users/srajp/apache-maven-3.5.3

 export PATH=$PATH:/Users/srajp/apache-maven-3.5.3/bin

Then check Maven version

$ mvn --version

If needed please see detailed steps on my blog on How to install Maven on MAC OS?



来源:https://stackoverflow.com/questions/38295609/install-maven-on-mac

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!