nexus mavn eclipse搭建本地仓库

     搭建本地仓库?很少的学生会做这种事情。不过还是有些人需要用到的,比如说我。当然我最主要的还只是用到第三方类库,比如我们在中央仓库找不到我们需要的构件。由于重装系统,所以得从新搭建,dt的是忘记怎么弄了,还得看文档。英文的文档伤不起啊。

     虽然看懂了,但是摆弄起来还真是费神,前后弄了两天终于弄好了,当然两天没有全部花在这上面。下面就把我搭建的过程记录下来,免得以后又忘记。

       我的环境是win7 64位+jdk7。我就不说jdk安装,环境配置啥的了。

       首先到http://www.sonatype.org/nexus/下载最新版本的仓库管理器nexus,现在只有2以上版本才支持jdk7。随便解压到任意一个文件夹下,然后运行bin/jsw/windows-x86-64下面的nexus.bat (注意了,我用的是64位系统所以运行in/jsw/windows-x86-64下面的nexus.bat 如果,如果是32位的话,运行in/jsw/windows-x86-32下面的nexus.bat )。然后在浏览器上输入本地仓库的网址http://localhost:8081/nexus/,登录进去账号是admin,密码admin123.nexus设置网上很多,这里不多介绍。接着安装eclipse的maven插件。安装完maven插件后,设置settings.xml。在eclipse中点击window--preferences--maven设置settings.xml,如果没有settings.xml的话自己添加一个,如图

settings.xml的主要内容如下

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<profiles>
		<profile>
			<id>nexus</id>
			<!--all requests to nexus via the mirror -->
			<repositories>
				<repository>
					<id>central</id>
					<url>http://127.0.0.1:8081/nexus/content/groups/public</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</repository>
			</repositories>
			<pluginRepositories>
				<pluginRepository>
					<id>central</id>
					<url>http://127.0.0.1:8081/nexus/content/groups/public</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</pluginRepository>
			</pluginRepositories>
		</profile>
	</profiles>
	<activeProfiles>
		<activeProfile>nexus</activeProfile>
	</activeProfiles>
</settings>
然后在某个项目的pom.xml里面添加如下配置

<repositories>
		<repository>
			<id>nexus</id>
			<url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
	</repositories>

到这里就大功告成。


  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值