MacOS设置Maven Home

  1. 下载Apache Maven,并解压到任意一个目录中。
# 个人习惯,将所有软件安装在/usr/local/tools 目录中
$ cd /usr/local/
$ sudo mkdir tools
  1. 设置Maven参数
    • 修改下载源为国内镜像
    • 设置repo






  
  /Volumes/ssd/dev/tools/maven/repo

  

  

  
  
    
  

  
  
    
  

  
  
    

    
  

  
  
    

  
        
        
          nexus-163
          *
          Nexus 163
          http://mirrors.163.com/maven/repository/maven-public/
        
        
  
  

  
  
    

    

    

    
        nexus-163
        
            true
        
        
        
          
              nexus-163
              Nexus 163
              http://mirrors.163.com/maven/repository/maven-public/
              default
              
                  false
              
              
                  true
              
          
      
      
          
              nexus-163
              Nexus 163
              http://mirrors.163.com/maven/repository/maven-public/
              
                  false
              
              
                  true
              
          
      
    

  

  

  1. 设置Maven Home
$ vi ~/.bash_profile
# 将下列内容插入到 .bash_profile 文件中,:wq 保存退出
export JAVA_HOME=`/usr/libexec/java_home`

export M2_HOME=/usr/local/tools/maven/apache-maven-3.5.0
export PATH=$M2_HOME/bin:$PATH
# 刷新配置,使立即生效
$ source ~/.bash_profile
  1. 测试Maven Home是否生效
$ mvn -v
# 返回如下信息,证明生效
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
Maven home: /usr/local/tools/maven/apache-maven-3.5.0
Java version: 1.8.0_181, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.4", arch: "x86_64", family: "mac"

你可能感兴趣的:(MacOS设置Maven Home)