maven的一些个人设置

一、下载

官网:http://maven.apache.org/download.cgi

二、环境变量

  新建系统变量MAVEN_HOME,位置是maven的解压路径

  Path在环境变量值尾部加入:%MAVEN_HOME%\bin

  在命令行输入 mvn -v,检查是否配置成功

三、maven设置

 在mven/conf/中修改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">
  <!-- 本地仓库 -->
  <localRepository>D:\java\apache-maven-3.6.2\maven_repository</localRepository>

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

  <mirrors>
  <!-- 添加国内镜像源 -->
    <mirror>
        <id>alimaven</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    </mirror>

    <!-- 中央仓库1 -->
    <mirror>
        <id>repo1</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://repo1.maven.org/maven2/</url>
    </mirror>

    <!-- 中央仓库2 -->
    <mirror>
        <id>repo2</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://repo2.maven.org/maven2/</url>
    </mirror> 
  </mirrors>
  <profiles>
  <!-- 设置maven默认的jdk版本 -->
      <profile>
        <id>jdk-1.8</id>    
        <activation>    
            <activeByDefault>true</activeByDefault>    
            <jdk>1.8</jdk>    
        </activation>  
        <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
        </properties>
    </profile>
  </profiles>
</settings>

四、在idea中配置maven

在idea中点击file -> setting,找到,配置

备注:一般maven里面会有一个默认的maven,它的maven设置和本地仓库一般在C:\Users\Administrator\.m2

posted @ 2019-07-19 22:47  匆匆、  阅读(218)  评论(0编辑  收藏  举报