Nexus_OOS_3.xx
2016-06-07 19:06
267 查看
Nexus Manager OSS 3.0 —Maven Repository
前言
网上基本搜不到 Nexus 3.0 版本以上的相关配置文档,最近刚好在弄,就顺便写下来了,当作笔记。nexus官方文档
1.下载
下载地址:http://www.sonatype.com/download-oss-sonatype
选择对应的版本下载,本文章以nexus-3.0.0-03-win64.zip版本为例。(其他版本大同小异)
Nexus 3.xx 版本除了Maven以外还支持 Docker ,NuGet ,npm ,Bower 。有时间的可以尝试一下。
2.解压
将下载好的zip格式的解压到指定目录。(Windows用户需注意目录路径不能含有中文,空格等字符)3.执行
3.0版本:进入到nexus的bin目录 nexus /start 执行cd D:\nexus-3.0.0-03\bin D:\nexus-3.0.0-03\bin>nexus /start
3.2版本:进入到nexus的bin目录 nexus /start 执行
cd D:\nexus-3.0.0-03\bin D:\nexus-3.0.0-03\bin>nexus.exe /run
默认应用地址是http://localhost:8081,若需要更改:
3.0版本:
打开 ..\nexus-3.0.0-03\etc\org.sonatype.nexus.cfg 修改端口: application-port 修改ip: application-host
3.2版本:
打开 ..\nexus\sonatype-work\nexus3\etc\nexus.properties 修改端口: application-port 修改ip: application-host
4.配置 Nexus
用浏览器打开 http://localhost:8081点击右上角Sign in 按钮登录。默认用户名:admin,密码:admin123
![](http://i.imgur.com/I3Brs3W.png)
点击齿轮状配置按钮,进入配置页面:
![](http://i.imgur.com/ys8U2l6.png)
进入Repository-Repositories
![](http://i.imgur.com/Q9RDd63.png)
Repository的type属性有:proxy,hosted,group三种。
proxy:即你可以设置代理,设置了代理之后,在你的nexus中找不到的依赖就会去配置的代理的地址中找
hosted:你可以上传你自己的项目到这里面
group:它可以包含前面两个,是一个聚合体。一般用来给客户一个访问nexus的统一地址。
简单的说,就是你可以上传私有的项目到hosted,以及配置proxy以获取第三方的依赖(比如可以配置中央仓库的地址)。前面两个都弄好了之后,在通过group聚合给客户提供统一的访问地址
至于format,因为本文讲的的 Maven Repository ,所以请选择maven2;
系统默认就有以上几个Repository。点击maven-public 确保已经将 maven-central,maven-releases以及maven-snapshots都包含在里面。
maven-releases : 默认配置只能上传 release版本的项目
maven-snapshots: 默认配置只能上传 snapshots版本的项目
如有特殊要求,可以自己创建一个Version policy 为Mixed的Repository。
以上配置就能满足一般需求了。
5.使用 mvn deploy 向 Nexus服务器 上传项目
maven setting.xml配置:<?xml version="1.0" encoding="UTF-8"?> <settings> <localRepository>E:/repository</localRepository> <mirrors> <mirror> <!--This sends everything else to /public --> <id>nexus</id> <mirrorOf>*</mirrorOf> <url>http://localhost:8081/repository/maven-public/</url> </mirror> </mirrors> <servers> <server> <id>nexus</id> <username>admin</username> <password>admin123</password> </server> </servers> </settings>
localRepository:本地库的地址
mirror:nexus地址
servers:nexus服务器登录名和密码
1.使用cmd上传
mvn deploy:deploy-file -DgroupId=com.cxx -DartifactId=fu -Dversion=1.0.0 -Dpackaging=jar -Dfile=D:\gworkspace\work\cxx\fu\target\fu.jar -Durl=http://localhost:8081/repository/maven-releases/ -DrepositoryId=nexus -s D:\maven-3.2.1\conf\settings.xml
参数说明:
-D 传入指定参数 分别对应pom中的 groupId,artifactId,version,packaging file 本地jar的路径 url Repository Url (请选择对应release,snapshots或mixed的url) repositoryId 对应setting.xml中server id -s setting.xml的路径(如果使用默认conf中的setting,则无需配置)
2.使用IDE上传
项目中的pom文件添加<distributionManagement> <repository> <id>nexus</id> <name>maven-releases</name> <url>http://localhost:8081/repository/maven-releases/</url> </repository> </distributionManagement>
id:对应setting.xml中server id
name:nexus Repository name
url:nexus Repository url
然后使用IDE自带的Maven deploy就可以了。
然后就可以在nexus中看到你上传的:
![](http://i.imgur.com/ETUBKka.png)
这样你的maven项目就能引用你所上传的项目了。
相关文章推荐
- maven学习
- maven插件maven-war-plugin的使用
- jenkins------部署项目到jboss eap下
- maven使用经验集
- java application maven项目打自定义zip包实例(推荐)
- window下安装和配置maven环境
- Eclipse使用maven搭建spring mvc图文教程
- 使用maven+eclipse搭建struts2开发环境
- myeclipse中使用maven前常见错误及解决办法
- Java随手笔记8之包、环境变量和访问控制及maven profile实现多环境打包
- maven利用tomcat插件部署远程Linux服务器的步骤详解
- maven搭建java ee项目图文教程
- Java的项目构建工具Maven的配置和使用教程
- maven中下载jar包源码和javadoc的命令介绍
- 表单重复提交处理总结
- Maven私服配置记录 Nexus
- hudson集成maven构建、多环境打包发版
- maven-war-plugin参数说明
- Maven学习笔记
- Docker+Jenkins+GIT+Tomcat实战持续化集成