首页 > 其他分享 >setting.xml文件配置释义

setting.xml文件配置释义

时间:2023-10-10 10:56:07浏览次数:38  
标签:xml false repository 仓库 jar maven setting 释义 aliyun

maven下载jar规则

  1. maven下载jar包优先从配置的本地仓库localRepository查找jar,找不到会去配置的远程仓库中下载jar
  2. 配置的远程仓库都有对应的id, 可以根据 标签填对应的仓库的id,代表,从这个仓库下载jar的时候,会走对应的镜像
  3. 如果下载不到jar,会报错
  4. plugin会从配置的pluginRepository中去下载,同上

setting.xml配置解释

server标签的作用

使用mvn install时,会把项目打的包安装到本地maven仓库,
使用mvn deploye时,会把项目打的包部署到远程maven仓库,这样有权限访问远程仓库的人都可以访问你的jar包
通过在pom.xml中使用 distributionManagement 标签,来告知maven 部署的远程仓库地址,例子如下
由于有的远程仓库有密码权限,如果没有在setting.xml中的<server>中进行配置,就会报出401错误,标签的id要和distributionManagement 中 仓库的id一致,详情见下面代码


	<distributionManagement>  
		<!-- 正式仓库 -->
	    <repository>  
	        <id>releases</id>  
	        <name>releases</name>  
			<url>http://nexus.xinfangsheng.info:8081/repository/maven-releases/</url>  
	    </repository> 
	     <!-- 快照仓库 -->
	    <snapshotRepository>
			<id>snapshot</id>  
		    <name>snapshot</name>  
		    <url>http://nexus.xinfangsheng.info:8081/repository/maven-snapshots/</url>  
    </snapshotRepository>  
</distributionManagement>

  <?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">

   <!-- 默认的值是${user.home}/.m2/repository -->
   <localRepository>E:\apache\repository</localRepository>

   <!-- 如果Maven要试图与用户交互来得到输入就设置为true,否则就设置为false,默认为true。 -->
   <interactiveMode>true</interactiveMode>

   <!-- 如果Maven使用${user.home}/.m2/plugin-registry.xml来管理plugin的版本,就设置为true,默认为false。 -->
   <usePluginRegistry>false</usePluginRegistry>

   <!-- 如果构建系统要在离线模式下工作,设置为true,默认为false。 如果构建服务器因为网络故障或者安全问题不能与远程仓库相连,那么这个设置是非常有用的。 -->
   <offline>false</offline>

   <servers>
       <!-- server
        | Specifies the authentication information to use when connecting to a particular server, identified by
        | a unique name within the system (referred to by the 'id' attribute below).
        |
        | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
        |       used together.
        |
       -->
       <!-- server标签的作用 ,如下 -->
       <!-- 使用mvn install时,会把项目打的包安装到本地maven仓库 -->
       <!-- 使用mvn deploye时,会把项目打的包部署到远程maven仓库,这样有权限访问远程仓库的人都可以访问你的jar包 -->
       <!-- 通过在pom.xml中使用 distributionManagement 标签,来告知maven 部署的远程仓库地址,-->

       <server>
           <id>snapshot</id>
           <username>developer</username>
           <password>*******</password>
           <filePermissions>664</filePermissions>
           <directoryPermissions>775</directoryPermissions>
       </server>
        <server>
           <id>releases</id>
           <username>developer</username>
           <password>***********</password>
           <filePermissions>664</filePermissions>
           <directoryPermissions>775</directoryPermissions>
       </server>
   </servers>

   <mirrors>
       <mirror>
           <id>aliyunmaven</id>
           <mirrorOf>*</mirrorOf><!--*代表所有的jar包都到阿里云下载-->
           <!--<mirrorOf>central</mirrorOf>--><!--central代表只有中央仓库的jar包才到阿里云下载-->
           <!-- maven 会有默认的id为 “central” 的中央仓库-->  
         <name>阿里云公共仓库</name>
           <url>https://maven.aliyun.com/repository/public</url>
       </mirror>

       <!--老版阿里云公共仓库-->
       <!--
       <mirror>
           <id>nexus-aliyun</id>
           <mirrorOf>central</mirrorOf>
           <name>Nexus aliyun</name>
           <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
       </mirror>
       -->
       
       <!-- 中央仓库在中国的镜像 -->
       <mirror>
           <id>maven.net.cn</id>
           <name>Mirror from Maven in china</name>
           <url>http://maven.net.cn/content/groups/public/</url>
           <mirrorOf>central</mirrorOf>
       </mirror>
   </mirrors>




   <!-- settings.xml中的profile是pom.xml中的profile的简洁形式。 它包含了激活(activation),仓库(repositories),插件仓库(pluginRepositories)和属性(properties)元素。 
       profile元素仅包含这四个元素是因为他们涉及到整个的构建系统,而不是个别的POM配置。 如果settings中的profile被激活,那么它的值将重载POM或者profiles.xml中的任何相等ID的profiles。 -->
    <!-- 如果setting中配置了 repository,则等于项目的pom中配置了 -->
   <profiles>
       <profile>
         <!-- 指定该 profile的id --> 
           <id>dev</id>
           <!-- 远程仓库-->
           <repositories>
               <!-- 阿里云远程仓库-->
               <repository>
                   <id>aliyun</id>
                   <name>aliyun maven Repository</name>
                   <url>https://maven.aliyun.com/repository/public</url>
                 <!-- 只从该仓库下载 release版本 -->
                   <releases>
                       <enabled>true</enabled>
                   </releases>
                   <snapshots>
                       <enabled>false</enabled>
                   </snapshots>
               </repository>
               <repository>
                   <id>spring-milestone</id>
                   <name>Spring Milestone Repository</name>
                   <url>http://repo.spring.io/milestone</url>
                   <releases>
                       <enabled>true</enabled>
                   </releases>
                   <snapshots>
                       <enabled>false</enabled>
                   </snapshots>
                   <layout>default</layout>
               </repository>
               <repository>
                   <id>spring-snapshot</id>
                   <name>Spring Snapshot Repository</name>
                   <url>http://repo.spring.io/snapshot</url>
                   <releases>
                       <enabled>false</enabled>
                   </releases>
                   <snapshots>
                       <enabled>true</enabled>
                   </snapshots>
                   <layout>default</layout>
               </repository>
           </repositories>
           <!-- 镜像,添加了会先从阿里云仓库下载-->
           <pluginRepositories>
             <!-- 插件仓库。插件从这些仓库下载 -->
               <pluginRepository>
                   <id>aliyun-plugin</id>
                   <url>https://maven.aliyun.com/repository/public</url>
                   <releases>
                       <enabled>true</enabled>
                   </releases>
                   <snapshots>
                       <enabled>false</enabled>
                   </snapshots>
               </pluginRepository>
           </pluginRepositories>
       </profile>
   </profiles>
   <!-- activations是profile的关键,就像POM中的profiles,profile的能力在于它在特定情况下可以修改一些值。 
       而这些情况是通过activation来指定的。 -->
   <!-- <activeProfiles/> -->
 <activeProfiles>
   <activeProfile>dev</activeProfile>
 </activeProfiles>
</settings>

标签:xml,false,repository,仓库,jar,maven,setting,释义,aliyun
From: https://www.cnblogs.com/zyjzzcl/p/17754053.html

相关文章

  • pom.xml/maven包
    Junit:测试<dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency></dependencies>写在测试类里:impo......
  • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance(xsi:schemaLocation详解)
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"中xsi的意思是:本xml文件中要用到某些来自xsi代表的“http://www.w3.org/2001/XMLSchema-instance”这个命名空间的元素 比如用来引入无命名空间schema文件的noNamespaceSchemaLocation="XXX";以及引入自带命名空间的sch......
  • mapper.xml 返回map格式
    //DAO层List<Map<String,Object>>selectRecord(Map<String,Object>map);  //mapper层<selectid="selectUpCountByTime"parameterType="map"resultType="java.util.HashMap">SELECTcreate_byasusernam......
  • .net core 接收xml、text/plain格式参数
    1、接收xmlcontroller中写法如下[HttpPost,ActionName("Sign_off")][Produces("application/xml")]//接收[Consumes("application/xml")]//返回publicasyncTaskSign_off([FromBody]XmlDocumentxmldoc){.....//你的业务逻辑}Startup.cs中的ConfigureSer......
  • python xml(ElementTree)
    pythonxml处理(ElementTree)1.模块导入fromxml.etree.ElementTreeimportElementTree,Element,SubElement2.对象概述ElementTree:表示整个xml层级结构Element:表示树形结构中的父节点SubElement:表示树形结构中的所有子节点,有些节点既可以是父节点,也可以是子节点3.Elem......
  • 【Azure Logic App】在Logic App中使用 Transfer XML组件遇见错误 undefined
    问题描述在AzureLogicApp中,使用TransformXML组件进行XML内容的转换,但是最近这个组件运行始终失败。 问题解答点击TransformXML组件上的错误案例,并不能查看到详细的错误消息。最后在AzureLogicApp的产品团队确认下,发现这是LogicApp自身升级后,当前LogicApp 依旧是旧版所引......
  • 【Azure Logic App】在Logic App中使用 Transfer XML组件遇见错误 undefined
    问题描述在AzureLogicApp中,使用TransformXML组件进行XML内容的转换,但是最近这个组件运行始终失败。 问题解答点击TransformXML组件上的错误案例,并不能查看到详细的错误消息。最后在AzureLogicApp的产品团队确认下,发现这是LogicApp自身升级后,当前LogicApp 依旧是......
  • TextCNN、DCNN、AttentionXML…你都掌握了吗?一文总结文本分类必备经典模型(二)
    https://mp.weixin.qq.com/s/f5SkoWD4BY_HDWfPi5R5ng 本专栏将逐一盘点自然语言处理、计算机视觉等领域下的常见任务,并对在这些任务上取得过SOTA的经典模型逐一详解。前往SOTA!模型资源站(sota.jiqizhixin.com)即可获取本文中包含的模型实现代码、预训练模型及API等资源。本......
  • 基于注解的装配、以及纯Java配置(不用xml)
    1、基于注解的装配参考课本以及陈恒spring教材很好理解,还参考了https://blog.csdn.net/huweiliyi/article/details/107641886(偏向代码分析)https://www.bilibili.com/video/BV1tM4y1Y7Jf/?spm_id_from=333.337.search-card.all.click&vd_source=af888e4b9fbc70c4d5e7a445796ae8a1(......
  • 4. spring完全注解开发,独立配置,不使用xml
    user类: 转换结果: 注入参数还是上一篇所说的方法  支持最低版本spring4.1运行方法要有所改变:原来的://获取配置文件ApplicationContextcontext=newClassPathXmlApplicationContext("application.xml");//配置文件自动扫描z......