小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

在Maven中設(shè)置Nexus私有服務(wù)為中央工廠(repository)

 昵稱27831725 2017-11-30

nexus中的倉庫列表



第一種方式:


<repositories>
  <repository>
  <id>nexus</id>
  <name>nexus Repository</name>
  <url>http://localhost:8081/nexus/content/repositories/central/</url>
  </repository>
  </repositories>

這種方式,Maven僅僅只會在nexus中的central中央工廠進行下載,而我們希望我們開發(fā)的releases、snapshots工廠都能下載



而這種方式會增加配置的復(fù)雜度,并且增加了配置文件的冗余,而沒增加一個都會去添加,這種方式不推薦使用


第二種方式:

為解決第一種方式,在nexus中提供了另外一種方式倉庫為:Public Repositories 類型為group  Repository Path為:http://localhost:8081/nexus/content/groups/public/

的方式




在pom.xml中我們只需要將url地址更改成它的地址即可,用了這個工廠就相當于用了Releases、Snapshots、3rd party 、Central這幾個工廠


 <repositories>
  <repository>
  <id>nexus</id>
  <name>nexus Repository</name>
  <url>http://localhost:8081/nexus/content/groups/public/</url>
  </repository>
  </repositories>


設(shè)置了之后,當我們有新的依賴,它就回去nexus中的倉庫中去下載



第二種方式,當還一個模塊的時候還的配置,這樣就不太方便,在企業(yè)開發(fā)中,我們需要設(shè)置一個共有的,因此第三中方式就來了



第三種方式


將自己設(shè)置的工廠中的settings.xml進行配置




 <profiles>
<profile>
      <id>nexusRepository</id>
       <repositories>
  <repository>
  <id>nexus</id>
  <name>nexus is Repository</name>
  <url>http://localhost:8081/nexus/content/groups/public/</url>
  <!-- 默認就是true -->
  <releases>
  <enabled>true</enabled>
  </releases>
  <!-- 默認是是false,需手動打開 設(shè)置為true -->
  <snapshots>
  <enabled>true</enabled>
  </snapshots>
</repository>
  </repositories>
    </profile>   
  </profiles>
<!-- 這里必須激活profile 才能生效 -->
  <activeProfiles>
    <activeProfile>nexusRepository</activeProfile>
  </activeProfiles>


這樣默認也是從nexus repository下載


第三種方式在nexus服務(wù)器停止的了,maven有會從maven的中央工廠mvnrepository進行下載,這是因為,Maven項目首先回去nexus中去找,當它發(fā)現(xiàn)nexus服務(wù)停止這個時候它就回去找Maven的工廠

在Maven的安裝包中的lib中的maven-model-builder-3.3.9.jar中的pom.xml,起配置如下

<repositories>
    <repository>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven./maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>


問題就是當我們發(fā)現(xiàn)Nexus服務(wù)停止了就不能下載,而只能從Nexus中下載,不允許去Maven中下載這就需要第四種方式


第四種方式:配置鏡像





配置如下

<mirrors>
   
    <mirror>
      <id>mirrorNexusId</id>
      <!-- *號代表所有工廠鏡像 ,當Maven進來之后,不管什么工廠都回去找URL的地址去下載 -->
      <mirrorOf>*</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://localhost:8081/nexus/content/groups/public/</url>
    </mirror>
  </mirrors>
<!-- 這里的工廠配置,是Maven中的,起snapshots是false,我們可以通過這種方式將其激活,就可以訪問中央工廠中snapshots -->
  <profiles>
<profile>
      <id>nexusRepository</id>
      <repositories>
   <repository>
     <id>central</id>
     <name>Central Repository</name>
     <url>https://repo.maven./maven2</url>
     <layout>default</layout>
     <snapshots>
       <enabled>true</enabled>
     </snapshots>
   </repository>
 </repositories>
    </profile>   
  </profiles>
<!-- 這里必須激活profile 才能生效 -->
  <activeProfiles>
    <activeProfile>nexusRepository</activeProfile>
  </activeProfiles>


第四種方式就是我們推薦的一種方式


    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多