Fork me on GitHub

maven本地安装与配置和修改使用国内aliyun源

win10安装maven配置

官网下载mavenhttp://maven.apache.org/download.cgi的zip压缩包,下载到本地。

解压maven到本地的目录中并创建reposity文件夹和settings.xml文件

 C:\maven 的目录

2018/07/03  19:47    <DIR>          .
2018/07/03  19:47    <DIR>          ..
2018/07/03  11:35    <DIR>          apache-maven-3.5.4
2018/07/05  14:04    <DIR>          repository
2018/07/03  19:47             2,346 settings.xml

在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">

<pluginGroups />
<proxies />
<servers />

<localRepository>C:/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>

打开控制面板\系统和安全\系统\高级环境设置,环境变量中添加

MAVEN_HOME C:\maven\apache-maven-3.5.4
在Path中添加:
%MAVEN_HOME%\bin

本地仓库修改位置需要添加环境变量:
M2_REPO C:/maven/repository

确定,到命令符窗口输入mvn -version查看mvn安装的版本信息。

这里要到用户目录下的.m2文件夹下面,将settings.xml文件复制一份放在这里

aliyun source URL
http://maven.aliyun.com/nexus/#welcome

本文标题:maven本地安装与配置和修改使用国内aliyun源

文章作者:Sui

发布时间:2018年07月05日 - 16:07

最后更新:2018年10月15日 - 15:10

原始链接:http://23171580.github.io/2018/07/05/maven本地安装与配置和修改使用国内aliyun源/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。