eclipse中的maven管理之仓库管理(四)

本文详细介绍了如何使用nexus搭建局域网仓库,并指导如何配置Maven以利用该仓库,包括创建仓库、添加镜像、更新索引、发布项目等关键步骤。


一:使用nexus来创建局域网的仓库

1.1下载nexus

1.2解压,并设置bin目录到环境变量

1.3配置nexus的nexus-2.3.1-01\bin\jsw\conf下的wrapper.conf;设置本地java路径;如图


1.4以管理员身份运行cmd.exe,执行nexus install

1.5安装成功后在cmd中执行nexus start

1.6启动成功后在浏览器地址栏访问:http://localhost:8081/nexus/index.html

1.7登录本地的nexus

用户名:admin

密码:admin123

二:创建局域网的仓库

仓库管理:

1.nexus的仓库类型讲解

2.创建私有仓库

2.1添加parent的使用仓库

修改本地maven的配置;setting文件位置:

为已经配置两个仓库添加本地镜像

  <mirrors>

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


2.2更新索引,将download Remote Indexes设置为true

保存之后去查看当前任务列表


完成后再进行搜索就可以使用了

2.3删除parent中的工厂设置,在settings.xml中进行工厂的设置

  <profiles>
	<profile>
	  <id>central-repos</id>
      <repositories>
        <repository>
          <id>central</id>
          <name>Central</name>
          <url>http://central</url>
		  <releases><enable>true</enable></releases>
		  <snapshots>
				<enabled>true</enabled>
		 </snapshots>
        </repository>
      </repositories>
    </profile>


其中url在配置完镜像之后就没有意义了。配置完成之后需要进行激活,开启如下代码

  <activeProfiles>
    <activeProfile>central-repos</activeProfile>
  </activeProfiles>

2.4项目的发布

然后修改parent的pom.xml文件,添加如下代码:

  
  <distributionManagement>
  
  	<snapshotRepository>
  		<id>user-snapshots</id>
  		<name>User Project SNAPSHOTS</name>
  		<url>http://192.168.0.199:8081/nexus/content/repositories/MyUserReposSnapshots/</url>
  	</snapshotRepository>
  	
  	<repository>
  		<id>user-releases</id>
  		<name>User Project Release</name>
  		<url>http://192.168.0.199:8081/nexus/content/repositories/MyUserReposRelease/</url>
  	</repository>
  	
  </distributionManagement>
在settings文件上面添加用户信息。给用户指定的权限

  <servers>
	 <server>
      <id>user-snapshots</id>
      <username>kh</username>
      <password>123456</password>
    </server>

	<server>
      <id>user-releases</id>
      <username>kh</username>
      <password>123456</password>
    </server>

然后在parent的pom.xml上执行maven build 输入或执行clean deploy;





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值