maven私服的使用

1,搭建maven私服略。。。maven私服搭建

2,搭建本地倉庫:

         2.1,maven下載解壓:

                   

          2.2,配置setting.xml文件

                  2.2.1,配置本地倉庫地址:D:/application/maven/repository (小編本地倉庫地址)                         

 <localRepository>D:/application/maven/repository</localRepository>

                 

                2.2.2,配置jdk:(不是必須配置:如果不配做,創建maven項目時需要手動導入jdk或jre )                       

<profile> 
		<id>jdk-1.8</id> 
		<activation> 
			<activeByDefault>true</activeByDefault> 
			<jdk>1.8</jdk> 
		</activation> 
		<properties> 
			<maven.compiler.source>1.8</maven.compiler.source> 
			<maven.compiler.target>1.8</maven.compiler.target> 
			<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> 
		</properties>
	</profile>

                      

               2.2.3,配置鏡像:                       

<!--私服鏡像-->
	<mirror> 
		<id>local-nexus</id> 
		<name>localmaven</name> 
		<url>http://192.168.2.101:8081/nexus/content/groups/public/</url> 
		<mirrorOf>central</mirrorOf> 
	</mirror>

                    

               2.2.4,配置私服構建(連接私服用的到 jar 等內容)        

<!-- 私服配置:還要配置 -->
	<profile>
		<id>nexus-maven</id>
		<repositories>
			<repository>
				<id>local-nexus</id>
				<url>http://192.168.2.101:8081/nexus/content/groups/public/</url>
				<releases>
					<enabled>true</enabled>
				</releases>
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</repository>
		</repositories>
	</profile>

                

             2.2.5,配置讓私服構建生效                

<!-- 私服:激活 id 爲 profile 的 id-->
  <activeProfiles> 
		<activeProfile>nexus-maven</activeProfile>
  </activeProfiles>

                

3,如果只是下載私服jar,而不發佈項目到maven私服,那麼配置已經配置完成:

              測試:隨便找一個本地沒有的jar進行測試

              

  4,如果還需要發佈項目到maven私服還需配置:

            4.1,pom.xml文件中添加:(可以單個配置)            

<!--正式版-->
<distributionManagement>
  <repository>
    <id>releases</id>
    <url>http://192.168.2.101:8081/nexus/content/repositories/releases</url>
  </repository>
</distributionManagement>
<!--快照版-->
<distributionManagement>
  <snapshotRepository>
    <id>snapshots</id>
    <url>http://192.168.2.101:8081/nexus/content/repositories/snapshots</url>
  </snapshotRepository>
</distributionManagement>

                          

             4.2,setting.xml配置:           

<!--私服配置:發佈使用-->
    <!--正式版-->
    <server>
      <id>releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <!--快照版-->
    <server>
      <id>snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

                       5,測試發佈:

           5.1, 右鍵項目——>run as ——>maven build——deploy

                 

              

       5.2,查看maven私服是否已經有了這個項目:

                       

             5.3,發佈後其他模塊開發人員就可以使用了:

                       只需要添加:                          

 <dependency>
      <groupId>dubbo-account-parent</groupId>
      <artifactId>dubbo-account-parent11</artifactId>
      <version>0.0.1-SNAPSHOT</version>
  </dependency>

 

 

 

 

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