Configure MAVEN environment variables under Mac computer
Open a terminal and use the Touch command to create a. bash_profile file
.bash_profile
Edit the file you just created. Bash_profile
.bash_profile
Input:
M2_HOME=/Users/lizhimin/Documents/maven/apache-maven-3.3.3PATH=$M2_HOME/bin:$PATHexport M2_HOMEexport PATH
(Note: Self-modifying according to your MAVEN version and path)
Save exit, use
source .bash_profile
(Make the modified environment variable effective//or completely exit the terminal before you come in.)
Verification, terminal input:
-v
Show:
Apache Maven3.2.3 (33F8C3E1027C3DDDE99D3CDEBAD2656A31E8FDF4;2014- 08-12t04: 58: 10+08:00) Maven home:/Users/ Lizhimin/documents/maven/apache-maven-3.2.3Java version: 1.7.0_75, vendor:oracle Corporationjava Home:/library/java/javavirtualmachines/jdk1.7 .0_75.jdk/contents/home/jredefault locale:zh_cn, platform Encoding:utf-8os Name: "Mac OS X", Version: "10.10.3", Arch: " Mac "
Other
If the input mvn-v displays the following:
Error: JAVA_HOME is not defined correctly. We cannot execute /usr/libexec/java_home/bin/java
You need to modify the. bash_profile file that we created
Add to:
export JAVA_HOME=$(/usr/libexec/java_home)
Then verify, OK.
2015-7-21 New
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Homeexport CLASS_PATH=$JAVA_HOME/libPATH=$PATH:$JAVA_HOME/binMAVEN_HOME=/Users/lizm/Documents/maven/apache-maven-3.3.3PATH=$MAVEN_HOME/bin:$PATHexport MAVEN_HOMEexport PATH
Scenario: Today's project development process, need to modify MAVEN update address, connect the company's Maven library, and then need to change the Setting.xml file in Maven package, encountered problems, before MAVEN configuration good, always use good, suddenly today terminal input mvn-v When there is a problem like this, the final fix. (I hope you're OK too)
Add:
Modify MAVEN's update path (one step, very simple):
Open apache-maven-3.3.3 > Conf > Settings.xml
Find the label modified to:
<Mirrors><!--Mirror | Specifies a repository mirror site to use instead of a given repository. The Repository that | This mirror serves have an ID, that matches, the mirrorof element of this mirror. IDs is used | For inheritance and direct lookup purposes, and must is unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>huma N Readable Name for this mirror.</name> <url>http://my.repository.com/repo/path</url> </mirro R>--<Mirror><Id>mirrorid</Id><Mirrorof>repositoryid</Mirrorof><Name>human readable Name for this Mirror.</Name><Url>http://my.repository.com/repo/path</Url></mirror> <mirror> <id>awifi-public</ id> <mirrorof>central</mirrorof> <name>awifi public for this Mirror. </name> < url>http://192.168.10.129:8081/nexus/content/groups/public </url> </mirror> </MIRRORS>
(Path to write your own company's path is good)
At this point, everything ok! Mr.--–@l
Configure MAVEN environment variables under Mac computer