搭建自己的maven私服

1. 下载nexus
下载地址: https://www.sonatype.com/download-oss-sonatype
2. 启动对应版本的nexus
…/nexus-2.14.8-01-bundle\nexus-2.14.8-01\bin\jsw
不同版本的nexus
3. 访问nexus
http://localhost:8081/nexus
默认用户名/密码 : admin/admin123
在这里插入图片描述
type表示仓库类型:

类型用途
hosted表示当前开发人员上传的,包括snapshots快照版本/releases稳定版本/3rd party第三方包三种仓库;表示当前开发人员上传的,包括snapshots快照版本/releases稳定版本/3rd party第三方包三种仓库;
proxy表示中央服仓库,包括snapshots快照版本/releases稳定版本两种仓库;

举个例子就是,
你上传jar包时,release版本就会上保存到hosted的releases仓库,snapshot版本就会保存到hosted的snapshots仓库;
你下载jar包时,就回到中央仓库找;

4. 初始化nexus
刚启动的nexus是搜不到jar包信息的,需要从中央仓库同步先
选中central仓库—>tab页中选中configuration---->download remote indexs 选择true
选择完后,nexus会创建一个任务从中央仓库同步jar包索引,耗时一两个小时;
5. 上传jar包
a)maven的settings.xml中配置nexus的认证信息

<servers>
	<server>
      <id>nexus-releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
	<server>
      <id>nexus-snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

b)项目的pom.xml中配置nexus的地址信息,此处id必须和settings中的id对应

 <distributionManagement>
        <repository>
            <id>nexus-releases</id>
            <name>nexus releases repository</name>
            <url>http://localhost:8081/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <name>nexus  snapshotRepository</name>
            <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

c) deploy jar包

6. 下载jar包
maven的settings.xml文件中配置
content/groups/public仓库表示同时可以从proxy/hosted仓库获取jar包

<profiles>
    <profile>
      <id>dev</id>
      <repositories>
        <repository>
  		<id>public</id>
  			<name>public repository</name>
  			<url>http://ip:8081/nexus/content/groups/public/</url>
  		<releases>
    			<enabled>true</enabled>
  		</releases>
  		<snapshots>
    			<enabled>true</enabled>
  		</snapshots>
	</repository>
      </repositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>dev</activeProfile>
  </activeProfiles>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值