maven安装教程

1. 安装maven前需要先安装java,并设置JAVA_HOME环境变量。(详见jdk安装教程
2. 将apache-maven-3.0.5-bin.zip放到d: eamwork中,点击右键,解压到当前文件夹中。
3. 右键点击我的电脑,点属性,打开系统属性对话框,点高级选项卡中的环境变量

4. 点击系统变量的新建按钮

5. 填入如下信息后点击确定

6. 找到变量path,双击打开


7. 将“%M2_HOME%in;”加入到变量值的最左侧(注意别落下分号),点击确定

8. 再点击确定关闭环境变量对话框

9. 按下win+R打开运行,输入cmd回车
10. 输入mvn –version回车,出现以下信息,则代表安装成功

11.在C:Usersadministrator.m2(或者C:Usersyour name.m2,.m2文件夹默认是隐藏的,需要显示隐藏文件才能看到)下建立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">
    
    <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/  

原文地址:https://www.cnblogs.com/gaoxinyu/p/3991160.html