maven中settings.xml文件的配置(本地仓库,镜像,jdk版本,)------自学总结

maven的settings.xml中可配置信息除了本地仓库,镜像,jdk版本,以及开发工具配置,还有很多信息,因为目前学习较浅,本文只涉及到这三块,后续实际项目涉及,再补充。如果问题,欢迎大神指点 !(忙了好几天,在周末一定把自己学习的东西全部补上)
———程序小白自学记
一:本地仓库、镜像
maven工作过程是先前本地仓库查找项目需要的jar包,如果没有会去镜像的地址(远程仓库)去下载所需jar包;
1.1本地仓库

 

翻译:用于存储构件的本地存储库maven
默认路径是~.m2/repository,一般情况都需要更改此路径
更改:在D盘准备文件夹MavenLocalReposity,根据自己情况创建文件夹即可,在settings.xml文件中加入以下代码:

` 
  <localRepository>D:\MavenLocalRepositylocalRepository>`

1.2镜像
通俗我称之为远程仓库,关于镜像settings.xml文件描述如下:

 
    -- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    
      mirrorId
      repositoryId
      Human Readable Name for this Mirror.
      http://my.repository.com/repo/path
    
     -->
  

翻译:指定要使用的存储库镜像站点,而不是给定的存储库。此镜像服务的存储库具有与此镜像的mirrorOf元素相匹配的ID。IDs用于继承和直接查找目的,并且必须是唯一的。`
这里我配置了两个:公司自有和aliyun,以下是aliyun的代码,mirror可根据实际需要更改

    <mirror>
        <id>nexus-aliyunid>
        <mirrorOf>*mirrorOf>
        <name>Nexus aliyunname>
        <url>http://maven.aliyun.com/nexus/content/groups/publicurl>
    mirror>

二:jdk版本
maven默认的jdk版本是低于1.6的,必须修改:有以下两种方式修改
2.1局部修改,在创建maven项目后,在pom.xml文件的标签中添加以下代码:

           <plugins>
                <plugin>
                    <groupId>org.apache.maven.pluginsgroupId>
                    <artifactId>maven-compiler-pluginartifactId>
                    <version>3.1version>
                    <configuration>
                        <source>1.7source>
                        <target>1.7target>
                    configuration>
                plugin>
            plugins>

2.2全局修改,在settings.xml文件的标签中添加以下代码:

<profile>     
    <id>jdkid>   
    <activation>        
          <activeByDefault>trueactiveByDefault>    
          <jdk>1.7jdk>      
     activation>  
     <properties>  
          <maven.compiler.source>1.7maven.compiler.source> 
          <maven.compiler.target>1.7maven.compiler.target> 
          <maven.compiler.compilerVersion>1.7maven.compiler.compilerVersion>   
     properties>
 profile>

三:sts配置settings
要在IDE集成开发工具中配置settings.xml文件,配置的本地仓库与你在xml文件中 本地仓库地址的地址一致
maven中settings.xml文件的配置(本地仓库,镜像,jdk版本,)------自学总结_第1张图片
maven中settings.xml文件的配置(本地仓库,镜像,jdk版本,)------自学总结_第2张图片

你可能感兴趣的:(maven中settings.xml文件的配置(本地仓库,镜像,jdk版本,)------自学总结)