一、下载
链接:Linux
提取码:oceg
链接:Windows
提取码:eq5a
二、安装
以Windows为例
1、将文件解压到没有中文没有空格的目录中,解压完后有两个文件夹
2、以管理员身份打开命令提示符(黑窗口)
3、进入解压的目录下nexus-2.12.0-01的bin中,输入nexus.bat install
三、启动
1、在同样的路径下,输入nexus.bat start
2、nexus-2.12.0-01-bundle\nexus-2.12.0-01\conf\nexus.properties
3、浏览器中输入http://localhost:8081/nexus
仓库的类型
1)hosted,宿主仓库, 部署自己的 jar 到这个类型的仓库,包括 releases 和 snapshot 两部
分, Releases 公司内部发布版本仓库、 Snapshots 公司内部测试版本仓库
2)proxy,代理仓库, 用于代理远程的公共仓库,如 maven 中央仓库,用户连接私服,私
服自动去中央仓库下载 jar 包或者插件。
3)group,仓库组,用来合并多个 hosted/proxy 仓库,通常我们配置自己的 maven 连接仓
库组。
4)virtual(虚拟):兼容 Maven1 版本的 jar 或者插件
四、应用
将自己的代码传到私服上
1、修改Maven的settings.xml,在<server></server>中加入
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
2、上传哪个模块的代码,就把对应模块的pom文件中加入以下内容
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases/</url> <!--注意修改IP地址-->
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
3、如果想把jar包上传到远程仓库,那就会执行Maven的默认生命周期最后一个阶段deploy,上传哪个模块就启动那哪个模块的deploy
注意:以上操作只能保证能上传jar包,不能保证可以下载jar包,配置以下文件,将保证既能上传又能下载jar包
1、修改Maven的settings.xml,在<profile></profile>中加入
<!-- 下载jar包配置 -->
<profile>
<!--profile的id -->
<id>dev</id>
<repositories>
<repository> <!--仓库id,repositories可以配置多个仓库,保证id不重复 -->
<id>nexus</id> <!--仓库地址,即nexus仓库组的地址 -->
<url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下载releases构件 -->
<releases>
<enabled>true</enabled>
</releases> <!--是否下载snapshots构件 -->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories> <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
<pluginRepository> <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
<id>public</id>
<name>Public Repositories</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
2、激活,在</profile>后</settings>加入
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
五、卸载
进入解压的目录下nexus-2.12.0-01的bin中,输入nexus.bat uninstall