IntellIJ IDEA 配置 Maven 以及 修改 默认 Repository

转载:https://www.cnblogs.com/phpdragon/p/7216626.html

一.配置Maven环境

1.下载apache-maven文件,选择自己需要的版本,地址: http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip

2.解压1所下载文件,本人解压到:D:servermavenapache-maven-3.5.0

3.配置Maven环境变量

a. MAVEN_HOME : D:servermavenapache-maven-3.5.0

b.PATH : %MAVEN_HOME%in;

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

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

其中会显示Java 配置环境以及Maven配置环境

2.配置D:servermaven中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 中的软件源,这步骤可以忽略。

好了,大功告成,,可以开心的撸代码了!

原文地址:https://www.cnblogs.com/hangxinggreat/p/9631782.html