maven安裝教程

1. 安裝maven前須要先安裝java,並設置JAVA_HOME環境變量。(詳見jdk安裝教程
2. 將apache-maven-3.0.5-bin.zip放到d:\teamwork中,點擊右鍵,解壓到當前文件夾中。
3. 右鍵點擊個人電腦,點屬性,打開系統屬性對話框,點高級選項卡中的環境變量

4. 點擊系統變量的新建按鈕

5. 填入以下信息後點擊肯定

6. 找到變量path,雙擊打開


7. 將「%M2_HOME%\bin;」加入到變量值的最左側(注意別落下分號),點擊肯定

8. 再點擊肯定關閉環境變量對話框

9. 按下win+R打開運行,輸入cmd回車
10. 輸入mvn –version回車,出現如下信息,則表明安裝成功

html

11.在C:\Users\administrator\.m2(或者C:\Users\your name\.m2,.m2文件夾默認是隱藏的,須要顯示隱藏文件才能看到)下創建settings.xml,內容以下java

<?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">
    
    <profiles>
        <profile>
            <id>myNexus</id>
            <repositories>
                 <repository>
                     <id>nexus</id>
                     <name>nexus</name>
                     <url>http://1.1.1.1:8081/nexus/content/groups/public</url>
                     <releases>
                         <enabled>true</enabled>
                     </releases>
                     <snapshots>
                         <enabled>true</enabled>
                     </snapshots>
                 </repository>
             </repositories>
             <pluginRepositories>
                 <pluginRepository>
                     <id>nexus</id>
                     <name>nexus</name>
                     <url>http://1.1.1.1:8081/nexus/content/groups/public</url>
                     <releases>
                         <enabled>true</enabled>
                     </releases>
                     <snapshots>
                        <enabled>true</enabled>
                     </snapshots>
                 </pluginRepository>
             </pluginRepositories>
         </profile>
     </profiles>
     <activeProfiles>
         <activeProfile>myNexus</activeProfile>
     </activeProfiles>
 </settings>

將其中的1.1.1.1替換成團隊的本身的nexus服務器地址,若是沒有,則能夠考慮使用oschina的maven庫,將url替換爲:http://maven.oschina.net/content/groups/public/  apache

相關文章
相關標籤/搜索