Maven配置

121 阅读1分钟

Maven配置


1 本地仓库

maven的conf目录中有 settings.xml ,是maven的配置文件,做如下配置:

<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
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <!-- 选择一个磁盘目录,作为本地仓库 -->
  <localRepository>D:\maven\myrepository</localRepository>

2 JDK配置

标签中 增加 一个 标签,限定maven项目默认的jdk版本.

内容如下:

<profiles>
    <!-- 在已有的profiles标签中添加profile标签 -->
    <profile>    
        <id>myjdk</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>
<!-- 让增加的 profile生效 -->
<activeProfiles>
    <activeProfile>myjdk</activeProfile>
</activeProfiles>

3 Maven改成自己设置的下载地址

在apache-maven-3.5.4\conf\setting加入

<!--setting.xml中添加如下配置-->
<mirrors>
    <mirror>
        <id>aliyun</id>  
        <!-- 中心仓库的 mirror(镜像) -->
        <mirrorOf>central</mirrorOf>    
        <name>Nexus aliyun</name>
        <!-- aliyun仓库地址 以后所有要指向中心仓库的请求,都会指向aliyun仓库-->
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>  
    </mirror>
</mirrors>

4 Maven改成自己设置的本地仓库

仓库改成本地.png