一、安装nexus
把Windows软件解压,得到两个目录:
进入nexus软件
进入conf
打开nexus.properties
nexus是b/s结构。
安装
在bin目录下进入cmd
安装命令
安装的过程中,发现以前安装过了。那么,我想重新安装怎么办?直接去服务里面,把之前的删掉。
安装好了。
服务里面有了nexus。
二、启动
命令行方式启动:
有些情况,可能会启动失败。解决方法:
三、仓库
启动成功了,我们通过浏览器来访问。输入:http://localhost:8081/nexus
点击右上角log in: 使用admin/admin123
仓库类型
3.1 Virtual 虚拟仓库
3.2 Proxy 代理仓库
代理仓库,可以认为是一个空的地址,只是做了一个跳转。比如Central的proxy,访问proxy的时候,就跳转到中央仓库去了。
3.3 Hosted 宿主仓库 本地仓库
有三种:
- 3rd party
- Releases
- Snapshots
我们自己做出来的工程默认的是snapshots。那我们在install的时候,就会把这个jar包自动放到snapshots里面。如果,我们的工程是Release,就会放到Releases里面。
3.4 Group 组
我们访问不同的仓库的时候,不同的仓库有不同的访问地址。而group管理了这几个仓库。那么,我们只要访问group仓库的地址,至于具体去哪个仓库拿jar包,由group仓库去查找。
四、私服的使用
需求:把dao放到私服上,然后service从私服上下载
需求 :将ssh_dao的这个工程打成jar包,并放入到私服上去
4.1 上传
发布到私服的命令是deploy。
在pom.xml里面配置发布的目标地址
<!-- 私服配置 -->
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
我们开发的工程snapshot会默认的放到snapshots里面。releases的这个地址放在这里,是为了表示,这里可以放多个地址。
目标地址填好了,那么,我们还要用户名密码。
<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
重新deploy
看看仓库里面
上传成功了。
4.2 下载
先关闭ssh-dao工程
ssh-service去私服的仓库里下载ssh-dao的依赖。
在maven的settings文件的<profiles>标签内添加配置。并且,添加激活的配置。
<profiles>
<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>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
本地仓库的ssh-dao删除
maven update ssh-service
从私服上下载了。
本地仓库又有了。
如果,我们的dao做了一点小的修改,会把版本号往上加
然后,service引用dao的版本号也要同步的变化。