16-私有仓库的设置

1.更新私有仓库的索引

 

 

2.设置镜像(设置setting.xml)

<!-- 配置镜像的目的是 使用私服中的jar包  如私服服务器中没有改jar由私服服务器去中央仓库下载 而不是每次都去中央仓库下 需要先去私服中找 如果没有下载到私服由私服提供给本地仓库-->
     <mirror>
      <id>nexusServ</id>
      <!--要镜像哪个工厂 如果 <repository>下的<id>1</id><repository>  和<repository>下的<id>2</id><repository> 都需要镜像 就需要在写成 <mirrorOf>1,2</mirrorOf>-->
      <mirrorOf>*</mirrorOf>
      <name>Human Readable Name for this Mirror</name>     
      <!-- 被镜像后的工厂<mirrorOf>*</mirrorOf>  不会在走pom.xml里在<repository>配置的url 而是走镜像的url-->
      <url>http://localhost:8081/nexus/content/groups/public/</url>
    </mirror>

  </mirrors>

 3.设置可以从私服中获取<snapshots>版本

<!-- 在apach-maven-3.0.4\lib\maven-buide-3.0下的pom.xml 它的repository节点下id等于central的<snapshots>为false我们也需要这个为true来获取版本进行测试调试 所以有了下变的设置
有的同仁想那我直接在每个工程中设置一下不行了嘛,但是在这里设置后以后每个工程都不需要在出现以下代码	         
	//<repository>
	  // <id>central</id>
	   //<name>Central Repositories</name>
	   //<url>http://localhost:8081/nexus/content/groups/public/</url>
	   //<releases><enabled>true</enabled></releases>
  	     //<snapshots><enabled>true</enabled></snapshots>
  	 //</repository>

  <profiles>
  	    <profile>
  	    	<id>central-repos</id>
		      <repositories>
			        <repository>
			          <id>central</id>
			          <name>central</name>
			          <url>http://central</url>
					     	<releases><enabled>true</enabled></releases>
					  		<snapshots><enabled>true</enabled></snapshots> 
			        </repository>
		      </repositories>
    	</profile>
<!--激活  </profiles>中配置的指定ID    -->
   <activeProfiles>
    <activeProfile>central-repos</activeProfile>
  </activeProfiles>

猜你喜欢

转载自hdzhangyanfeng.iteye.com/blog/2097413