您的位置:首页 > 其它

关于maven的仓库的详解,基于nexus

2017-09-19 09:09 204 查看
<!--可以在父类设置一个nexus的私有工厂 -->

  <!-- <repositories>

   <repository>

   <id>nexus</id>

   <name>nexus Repository</name>

   localhost可以是任意的ip,它都会去相应工厂找

   <url>http://localhost:8081/nexus/content/groups/public/</url>

   <releases>

   默认是打开的,他会下载releases版本的

   <enabled>true</enabled>

   </releases>

   <snapshots>

   默认是false,

   <enabled>true</enabled>

   </snapshots>

   </repository>

  </repositories> -->

 <!--只有这里激活了相应id才说明使用那个的私服-->

  <activeProfiles>

    <activeProfile>nexusRep</activeProfile>

  </activeProfiles>

上面的问题是当其它没继承的模块或其他项目时又需要设置一遍,因此可以通过去maven的setting.xml中设置私服,当需要那个仓库管理器统一激活

<!-- 在这里建立不同的私服,这里为nexus的-->
<profile>

      <id>nexusRep</id>
<repositories>
<repository>
<id>nexus</id>
<name>nexus Repository</name>
<!-- localhost可以是任意的ip,它都会去相应工厂找-->
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<!-- 默认是打开的,他会下载releases版本的 -->
<enabled>true</enabled>
</releases>
<snapshots>
<!-- 默认是false, -->
<enabled>true</enabled>
</snapshots>
</repository>
 </repositories>

    </profile>

<!--只有这里激活了相应id才说明使用那个的私服-->

  <activeProfiles>

    <activeProfile>nexusRep</activeProfile>

  </activeProfiles>

当你的私服nexus关闭了,它会去maven的maven-model-builder-3.5.0.jar\org\apache\maven\model \pom-4.0.0.xml中的配置的中央工厂找。

如果你不允许直接去中央工厂找,必须通过私服(nexus)找,当私服找不到时就停止下载依赖包,就需要在settings.xml配置镜像

 <!--*代表所有激活的工厂,url设置为只能下载依赖包的私服-->
<!--  <mirror>

      <id>nexusMirror</id>

      <mirrorOf>*</mirrorOf>

      <name>Human Readable Name for this Mirror.</name>

      <url>http://localhost:8081/nexus/content/groups/public/</url>

    </mirror>-->

<!-- 在这里建立不同的私服,这里为nexus的-->
<profile>

      <id>nexusRep</id>
<repositories>
<repository>
<id>nexus</id>
<name>nexus Repository</name>
<!-- localhost可以是任意的ip,它都会去相应工厂找-->
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<!-- 默认是打开的,他会下载releases版本的 -->
<enabled>true</enabled>
</releases>
<snapshots>
<!-- 默认是false, -->
<enabled>true</enabled>
</snapshots>
</repository>
 </repositories>

    </profile>
<!--把maven-model-builder-3.5.0.jar\org\apache\maven\model \pom-4.0.0.xml的中央工厂设置一下-->
<!--<profile>

      <id>centralRep</id>
 <repositories>
<repository>
 <id>central</id>
 <name>Central Repository</name>
 <url>*</url>
 <layout>default</layout>
 <snapshots>
<enabled>true</enabled>
 </snapshots>
</repository>
 </repositories>

    </profile>-->

<activeProfiles>

    <activeProfile>nexusRep</activeProfile>

  </activeProfiles>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: