Maven 私服 自动上传部署(附快速镜像)

一、配置Maven的 settings.xml

 nexus私服是需要登陆的(可配置免登陆),在settings.xml的配置<servers></servers>

如下:

<servers>
	<server>   
		<id>nexus</id>   
		<username>admin</username>
		<password>xxxxx</password>   
	</server>
	<server>   
		<id>central</id>   
		<username>admin</username>   
		<password>xxxx</password>   
	</server>
</servers>

二、 配置项目的 pom.xml

添加如下:

  <distributionManagement>
   <repository>
    <id>nexus</id>
    <name>Internal Releases</name>
    <url>http://168.10.132.150:8081/nexus/content/repositories/thirdparty/</url>
   </repository>
  </distributionManagement>

三、其它问题

请确保 maven 私服开启了上传部署策略:

1.登录到maven私服,点击“Repositories”在右侧的列表中找到要使用的私服仓库,最右侧为仓库地址(复制这个地址,私服镜像和上传都要用到)

2.点击该仓库后,在下面找到“Configuration”标签页,找到“Deployment Policy”项,将其修改为:Allow Redeploy

3.点击最下面的“Save”保存配置即可,之后在项目根目录下运行命令:mvn deploy


mvn deploy:会自动编译、打包、上传构件到私服,整个过程一键搞定!!


附件:

经常使用的几个比较快的镜像:

<mirrors>
    <!-- 私服-->
	<mirror>
		<id>nexus</id>
		<mirrorOf>nexus</mirrorOf>
		<url>http://168.10.132.150:8081/nexus/content/groups/public/</url>
	</mirror>
	
	 <mirror>
        <id>repo2</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://repo2.maven.org/maven2/</url>
    </mirror>
    
    <mirror>
        <id>ui</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://uk.maven.org/maven2/</url>
    </mirror>
    <mirror>
        <id>ibiblio</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
    </mirror>
	<mirror>
		<id>alimaven</id>
		<name>aliyun maven</name>
		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
		<mirrorOf>central</mirrorOf> 
	</mirror>
	
	<mirror>
		<id>repo1</id>
		<mirrorOf>central</mirrorOf>
		<!--<mirrorOf>*</mirrorOf>-->
		<url>https://repo1.maven.org/maven2/</url>
	</mirror>
	<mirror>
		<id>sprintio</id>
		<mirrorOf>central</mirrorOf>
		<name>Human Readable Name for this Mirror.</name>
		<url>https://repo.spring.io/libs-snapshot/</url>
	</mirror>
    <mirror>
        <id>jboss-public-repository-group</id>
        <mirrorOf>central</mirrorOf>
        <name>JBoss Public Repository Group</name>
        <url>http://repository.jboss.org/nexus/content/groups/public</url>
    </mirror>
  </mirrors>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值