maven配置解析

1、配置本地仓库

<localRepository>D:\Program Files\repository</localRepository>

2、配置远程仓库的服务器的验证信息

<servers>
    <server>
    	<id>nexus-releases</id>
      	<username>deployment</username>
      	<password>deployment@123</password>
    </server>

    <server>
    	<id>nexus-snapshot</id>
      	<username>deployment</username>
      	<password>deployment@123</password>
    </server>
</servers>

3、配置镜像:通过远程仓库的id拦截指定远程仓库的请求,将其转到镜像网站

        id:镜像的唯一标识
        mirrorof:通过id指哪个远程仓库被镜像了
        name:名字,可以说明镜像的作用
        url:镜像仓库的地址

<mirrors>
    <!--镜像
        id:镜像的唯一标识
		mirrorof:通过id指哪个远程仓库被镜像了
		name:名字,可以说明镜像的作用
		url:镜像仓库的地址
		-->
    <mirror>
      <id>nexus-center</id>
      <mirrorOf>*</mirrorOf>
      <name>Public Repositories</name>
      <url>http://101.132.72.39:28881/nexus/content/groups/public/</url>
    </mirror>
</mirrors>

4、配置远程仓库服务器,maven默认配置了中央仓库,在这里我们可以配置私服

<profiles>
	<profile>
  		<id>snapshots-global</id>
		<!--激活配置-->
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
      	
	  	<repositories>
		    <!--远程仓库
				id:远程仓库的唯一标识
				name:名字,可以说明镜像的作用
				url:远程仓库的地址
				maven中的仓库分为两种,snapshot快照仓库和release发布仓库。
				snapshot快照仓库用于保存开发过程中的不稳定版本,
				release正式仓库则是用来保存稳定的发行版本。
				定义一个组件/模块为快照版本,只需要在pom文件中在该模块的版本号
                后加上-SNAPSHOT即可(注意这里必须是大写)
				-->
	        <repository>
	            <id>nexus-center</id>
	            <name>nexus-center</name>
	            <url>http://101.132.72.39:28881/nexus/content/groups/public/</url>
	            <releases>
	                <enabled>true</enabled>
	            </releases>
	            <snapshots>
	                <enabled>true</enabled>
	            </snapshots>
	        </repository>
	    </repositories>
	    <pluginRepositories>
            <!--插件的远程仓库-->
	        <pluginRepository>
	            <id>nexus-center</id>
	            <name>nexus-center</name>
	            <url>http://101.132.72.39:28881/nexus/content/groups/public/</url>
	            <releases>
	                <enabled>true</enabled>
	            </releases>
	            <snapshots>
	                <enabled>false</enabled>
	            </snapshots>
	        </pluginRepository>
	    </pluginRepositories>
  	</profile>
</profiles>

5、依赖的加载流程,先查询本地仓库,若本地仓库没有该依赖,则到注册且激活的远程仓库的查询,若此远程仓库被镜像了,则转而去镜像服务器查询,若镜像服务器没有该依赖,则去中央仓库查询,若中央仓库也被镜像了,则转而去相应的镜像服务器查询。注意中央仓库若被镜像了,则就算对应的镜像服务器挂了也不会中央仓库查询依赖。

6、nexus是唯一免费搭建maven仓库的软件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值