一、下载nexus
地址:https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/oss/nexus-2.14.8-01-bundle.zip;
二、解压nexus-2.14.8-01-bundle.zip到指定的盘符:
三、在bin/jsw下有不同的版本,根据自己的系统选择正确的版本,这里选择window 64位操作系统的版本。
四、启动服务
介绍:
console-nexus.bat 是以命令窗口的形式启动,关闭后服务停止
install-nexus.bat 是设置开机启动,在服务中可以看成到该服务为开机自动启动(推荐使用这种方式启动)
stop-nexus.bat 是停止服务
uninstall-nexus.bat 是卸载nexus
启动服务:
看控制台:
五、服务配置
启动后输入:http://localhost:8081/nexus
进入在右上角Login登录,初始用户名:admin 密码:admin123:
登陆后界面:
1、修改登录密码:如图选中admin选项,然后右键:
2、配置参数,将Download Remote Indexes 设置为true
3、添加第三方jar包
3.1、选择和填写参数(groupId、artifactId、version)都要填写
3.2、选择上传的jar包
六、项目调用方法
1、配置maven的settings.xml文件
1.1、设置jar包保存的本地目录(我设置的是D盘)
<!--设置自己的maven本地仓库-->
<localRepository>D:/Program Files/maven_repository/repository</localRepository>
1.2、根据私服设置私服地址
<mirrors>
<mirror>
<!--此处配置所有的构建均从私有仓库中下载 *代表所有,也可以写central -->
<id>nexus</id>
<name>nexus</name>
<!-- * 表示让所有仓库使用该镜像-->
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
1.3 在setting.xml配置文件中增加配置:(只需要修改下图标注的Releases/Snapshots中对应的地址):
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus-rs</id> <!--正式仓库id-->
<!--name随便-->
<name>Nexus Release Snapshot Repository</name>
<!--地址是nexus中repository(Releases/Snapshots)中对应的地址-->
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>nexus-snapshots</id>
<!--地址是nexus中repository(Releases/Snapshots)中对应的地址-->
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<!--插件仓库地址,各节点的含义和上面是一样的-->
<pluginRepositories>
<pluginRepository>
<id>nexus-rs</id>
<name>Nexus Release Snapshot Repository</name>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>nexus-snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!--激活配置-->
<activeProfiles>
<activeProfile>nexus</activeProfile> <!--profile下的id-->
</activeProfiles>
1.4 在eclipse中更换setting.xml文件: