配置Maven環境 settiing.xml

一.配置Maven環境

1.下載apache-maven文件,選擇自己需要的版本,

2.解壓1所下載文件,本人解壓到:D:\server\maven\apache-maven-3.5.0

3.配置Maven環境變量

a. MAVEN_HOME : D:\server\maven\apache-maven-3.5.0

b.PATH : %MAVEN_HOME%\bin;

c. MAVEN_OPTS : -Xms128m -Xmx512m -Duser.language=zh -Dfile.encoding=UTF-8

4.在CMD中輸入mvn -v,如出現下列信息,表示配置成功。

其中會顯示Java 配置環境以及Maven配置環境

 

二.修改Maven倉庫路徑

1.在D盤(個人根據自身情況而定)新建文件,如下:

 

2.配置D:\server\maven\中setting.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">
    
    <pluginGroups />
    <proxies />
    <servers />
    
    <localRepository>D:/server/maven/repository</localRepository>
    
    <mirrors>
        <mirror>
            <id>alimaven</id>
            <mirrorOf>central</mirrorOf>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
        </mirror>
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
        <mirror>
            <id>central</id>
            <name>Maven Repository Switchboard</name>
            <url>http://repo1.maven.org/maven2/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
        <mirror>
            <id>repo2</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://repo2.maven.org/maven2/</url>
        </mirror>
        <mirror>
            <id>ibiblio</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
        </mirror>
        <mirror>
            <id>jboss-public-repository-group</id>
            <mirrorOf>central</mirrorOf>
            <name>JBoss Public Repository Group</name>
            <url>http://repository.jboss.org/nexus/content/groups/public</url>
        </mirror>
        <mirror>
            <id>google-maven-central</id>
            <name>Google Maven Central</name>
            <url>https://maven-central.storage.googleapis.com
            </url>
            <mirrorOf>central</mirrorOf>
        </mirror>
        <!-- 中央倉庫在中國的鏡像 -->
        <mirror>
            <id>maven.net.cn</id>
            <name>oneof the central mirrors in china</name>
            <url>http://maven.net.cn/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>
    
</settings>

三.IntellIJ IDEA 中配置Maven

Idea 自帶了apache maven,默認使用的是內置maven,所以我們可以配置全局setting,來調整一下配置,比如遠程倉庫地址,本地編譯環境變量等。

1.打開Settings,在輸入框輸入maven,如圖

 

 

2.如果本地設置了MAVEN_OPTS 系統環境變量,這個步驟可以忽略。

 

3.如果配置了本地apache-maven setting.xml 中的軟件源,這步驟可以忽略。

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章