maven項目配置時私服nexus以及倉庫repository的一些情況

前幾日碰到了一個項目,主要是基於一個開源項目的二次開發,

主項目的pom.xml有如下代碼段

<!-- 設定除中央倉庫(repo1.maven.org/maven2/)外的其他倉庫,按設定順序進行查找. -->
	<repositories>

		<!-- 如有Nexus私服, 取消註釋並指向正確的服務器地址. <repository> <id>nexus-repos</id> <name>Team 
			Nexus Repository</name> <url>http://localhost:8081/nexus/content/groups/public</url> 
			</repository> -->

		 <repository>
			<id>central-repos</id>
			<name>Central Repository</name>
			<url>http://repo.maven.apache.org/maven2</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>

		<repository>
			<id>springsource-repos</id>
			<name>SpringSource Repository</name>
			<url>http://repo.springsource.org/libs-milestone-local</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
這裏就是爲了防止私服中央倉庫沒有找到jar的時候需要本地直接去springsource-repos引用倉庫尋找。

這裏可以把這裏面的一些倉庫repostory的url在nexus中進行設置。

1.添加proxy repository。然後設置相應的id,name,以及url。

2.然後添加需要使用到的repository到 public group中,如下 

設置好之後進行刷新

查看

是否有這樣的  remoxxxx。就是被阻塞了。這個時候 這個repository就要在pom.xml文件中進行配置了。

---------------------------------------------------------------------------------------------------------------------------------------

這時候要配置maven的鏡像。

打開maven安裝目錄下的conf-----》settings.xml文件。

 <mirrors>
   <mirror>
      <id>central</id>
      <mirrorOf>*</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://localhost:8081/nexus/content/groups/public/</url>
    </mirror>

xxx

下面還要配置一個

<profiles>
  
   <profile>
     
		<id>central-repos</id>
      <repositories>
        <repository>
          <id>central</id>
          <name>central_nexus</name>
          <url>http://localhost:8081/nexus/content/groups/public/</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
然後要啓動這個profile。

<activeProfiles>
    <activeProfile>central-repos</activeProfile>
  </activeProfiles>
  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
這樣就可以使用了。具體這個配置還是參考孔浩老師的maven配置吧。

另外記得配置用戶名和密碼,一般使用admin和admin123就可以了。

 <server>
      <id>test-log-snapshot</id>
      <username>deployment</username>
      <password>deployment123</password>
    </server>
	<server>
      <id>user-releases</id>
      <username>deployment</username>
      <password>deployment123</password>
    </server>
	<server>
      <id>user-snapshots</id>
       <username>deployment</username>
      <password>deployment123</password>
    </server>

這裏把上面的改成admin和admin123吧。具體忘了。。。。。╮(╯▽╰)╭ 

然後一直重啓eclipse,update  maven項目。

看下可以否。。。



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章