1、nexus3的安装和启动服务器
1.在官网下载nexus3maven
2.安装nexusurl
解压到指定文件夹D:\nexus3\,获得 nexus-3.16.2-01 文件夹和 sonatype-work 文件夹,nexus-3.16.2-01文件夹放的是nexus服务器相关的文件,sonatype-work放的是nexus工做的数据文件,上传下载的jar包就在这个文件夹下面。spa
在命令提示符中进去D:\nexus3\nexus-3.16.2-01\bin文件夹,执行命令:nexus /run,访问http://localhost:8081。.net
2、nexus3的使用命令行
1.登陆nexus3d
使用默认用户admin,密码admin123,登陆。代理
2.管理本地仓库code
Nexus有3个类型的数据仓库,分别是hosted,proxy,group。server
hosted 宿主仓库:主要用于部署没法从公共仓库获取的构件以及本身或第三方的项目构件;
proxy 代理仓库:代理公共的远程仓库;
group 仓库组:Nexus 经过仓库组统一管理多个仓库,这样咱们在项目中直接请求仓库组便可请求到仓库组管理的多个仓库。
Nexus预约义了2个本地仓库,分别是maven-releases, maven-snapshots。
maven-releases:这里存放咱们本身项目中发布的构建, 一般是Release版本的。
maven-snapshots:这个仓库很是的有用, 它的目的是让咱们能够发布那些非release版本, 非稳定版本。
咱们还能够本身建立仓库
若是是建立的proxy仓库或者hosted仓库,须要添加到公共仓库里。
3.上传本地jar包
4.在maven中配置私服,编辑setting.xml
<servers> <server> <!--这是server的id(注意不是用户登录的id),该id与distributionManagement中repository元素的id相匹配。 --> <id>nexus</id> <username>admin</username> <password>admin123</password> </server> </servers> <!--为仓库列表配置的下载镜像列表。 --> <mirrors> <mirror> <!--该镜像的惟一标识符。id用来区分不一样的mirror元素。 --> <id>nexus</id> <!--此处配置全部的构建均从私有仓库中下载 *表明全部,也能够写central --> <mirrorOf>*</mirrorOf> <name>central repository</name> <!--该镜像的URL。构建系统会优先考虑使用该URL,而非使用默认的服务器URL。 --> <url>http://127.0.0.1:8081/repository/maven-public/</url> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <!--远程仓库列表,它是Maven用来填充构建系统本地仓库所使用的一组远程项目。 --> <repositories> <!--发布版本仓库--> <repository> <id>nexus</id> <!--地址是nexus中repository(Releases/Snapshots)中对应的地址--> <url>http://127.0.0.1:8081/repository/maven-public/</url> <!--true或者false表示该仓库是否为下载某种类型构件(发布版,快照版)开启。 --> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> </profiles> <!--激活配置--> <activeProfiles> <!--profile下的id--> <activeProfile>nexus</activeProfile> </activeProfiles>
经过命令行上传jar到nexus:
mvn deploy:deploy-file -DgroupId=com.sgcc.ams -DartifactId=ams-base -Dversion=1.7.0 -Dpackaging=jar -Dfile=C:\develop\lib\ams-base-1.7.0.jar -Durl=http://127.0.0.1:8081/repository/maven-releases/ -DrepositoryId=nexus
在项目中配置私服,pom.xml中添加
<!--上传到nexus仓库中,配合mvn deploy:deploy--> <distributionManagement> <repository> <id>nexus</id> <name>Nexus snapshots Repository</name> <!--snapshots仓库 --> <url>http://127.0.0.1:8081/repository/maven-snapshots/</url> </repository> </distributionManagement>
经过命令行执行mvn deploy便可。
内容部分参考:
https://blog.csdn.net/cool_summer_moon/article/details/78779530https://blog.csdn.net/u013887008/article/details/79429973