天天看點

Maven-CentOS 7安裝maven原文:https://www.cnblogs.com/116970u/p/11211963.html一.下載下傳maven二.安裝三.替換jar包下載下傳源為阿裡雲

原文:https://www.cnblogs.com/116970u/p/11211963.html

一.下載下傳maven

版本:apache-maven-3.6.3-bin.tar.gz

官網:https://maven.apache.org/download.cgi

百度雲盤:https://pan.baidu.com/s/1QKFL-GurbZ7xJbkz4BRBBg  提取碼:62e9 

二.安裝

在linux環境中建立maven目錄,/usr/local/maven,将maven安裝包上傳至此目錄中

配置環境變量 ,編輯環境變量檔案

vim /etc/profile
           

将下面兩行 代碼加入到檔案最後 然後儲存

export MAVEN_HOME=/usr/local/apache-maven-3.6.3
export PATH=${MAVEN_HOME}/bin:${PATH}
           

重新整理環境變量 

source /etc/profile
           

mvn -version 檢視安裝版本  

三.替換jar包下載下傳源為阿裡雲

編輯配置檔案

vim /usr/local/apache-maven-3.6.3/conf/settings.xml
           

替換内容為

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">


  <mirrors>
	<mirror>  
            <id>nexus-aliyun</id>  
            <mirrorOf>central</mirrorOf>  
            <name>Nexus aliyun</name>  
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
        </mirror>  
        <mirror>  
            <id>net-cn</id>  
            <mirrorOf>central</mirrorOf>  
            <name>Nexus net</name>  
            <url>http://maven.net.cn/content/groups/public/</url>  
        </mirror>  
  </mirrors>


  <profiles>
	<profile>  
            
            <repositories>  
                <repository>  
                    <id>nexus</id>  
                    <name>local private nexus</name>  
                    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
                    <releases>  
                        <enabled>true</enabled>  
                    </releases>  
                    <snapshots>  
                        <enabled>false</enabled>  
                    </snapshots>  
                </repository>  
            </repositories>  
            <pluginRepositories>  
                <pluginRepository>  
                    <id>nexus</id>  
                    <name>local private nexus</name>  
                    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
                    <releases>  
                        <enabled>true</enabled>  
                    </releases>  
                    <snapshots>  
                        <enabled>false</enabled>  
                    </snapshots>  
                </pluginRepository>  
            </pluginRepositories>
	</profile>
  </profiles> 

 
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>