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

IDEA版本:

IntelliJ IDEA 2017.2
Build #IU-172.3317.76, built on July 15, 2017
Licensed to Administrator

JRE: 1.8.0_152-release-915-b5 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 7 6.1

IntelliJ IDEA下载地址:https://www.jetbrains.com/idea/download/#section=windows

IntelliJ IDEA 是Java开发利器,用社区版不爽,干催就用旗舰版,这个是收费的,需要licence。 

如果你资金充足,请自行购买收费版的Idea:https://www.jetbrains.com/idea/buy。

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

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

猜你喜欢

转载自blog.csdn.net/xiaoguigui520/article/details/83828104