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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

java的艺术

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值