window Maven私服搭建——nexus
- Maven私服搭建——nexus
1、下载nexus
https://www.sonatype.com/download-oss-sonatype
bundle自带了jetty容器
下载其中一个,解压后内容是一样的,tar.gz下载更快,因为压缩比更高。

2、安装
nexus
2.1解压压缩包

得到


2,2安装nexus
由于下载的版本bundle自带jetty容器,故不需要额外的配置就可以启动。
在windows环境安装
找到路径:D:\nexus2.8\nexus-2.8.1-01\bin\jsw\windows-x86-32
事实上,你需要先安装好jdk,你的jdk是32位的就选择windows-x86-32,你的jdk是64位的就选择windows-x86-64
可以参考:JDK安装和JAVA环境变量的设置

然后,先尝试一下环境是否正常:
点击
console-nexus.bat
如果没有报错,访问
http://localhost:8081/nexus/
8081端口是默认的,如果要修改,打开路径D:\nexus2.8\nexus-2.8.1-01\conf
下的nexus.properties 文件进行修改

点击右上角的 Log
In 登陆,
默认登陆用户名:admin,密码:admin123
3、nexus
仓库分类
maven会向nexus请求jar包,nexus可以有多个仓库,每个仓库都有一个地址,maven的配置文件可以像从maven的中央仓库请求资源一样从nexus请求资源。
maven的中央仓库缺少一些特定版权的jar包,本地的正在开发的jar包,nexus则可以进行对这些归类管理,比如apache的,Oracle jdbc驱动的 ,包括本地项目等。
nexus即可以建立多个仓库,也可以把已存的仓库组合起来作为一个仓库。
分类示意图如下:

4、maven的依赖范围

当存在依赖关系时

5、maven的快照(SNAPSHOT)版本和发布(release)版本
当项目处于开发阶段,版本要被声明为类似于
2.1-SNAPSHOT的模式,当该项目版本稳定则可将版本写为 2.1
开发阶段的版本不应对外发布,发布版本的不应依赖快照(SNAPSHOT)版本。
此外,maven还有一个
最新版本,即latest,这个是取最新的版本,包含快照版本和发布版本。
6、maven镜像
如果仓库X可以提供仓库Y存储的所有内容,那么就可以认为X是Y的一个镜像。换句话说,任何一个可以从仓库Y获得的构件,都能够从它的镜像中获取。
比如,http://maven.net.cn/content/groups/public/是中央仓库http://repo1.maven.org/maven2/在中国的镜像,同样,我们也可以使用私服来作为镜像。
所以,目前就是这样的结构,nexus负责组织各种仓库作为私服,对外提供访问地址,然后在maven的配置文件settings.xml中配置
| 1 2 3 4 5 6 | <mirror>  <id>internal-respository</id>  <name>Internal Repository manager</name>  <url>http://localhost:8081/maven2/</url>   <mirrorof>*</mirrorof></mirror> | 

7、在neuxs中新建宿主仓库,

双击新建宿主仓库,在下面面板填写配置信息

8、新建代理仓库

代理仓库的背后是远程仓库。

9、创建仓库组

然后选择已经配置好的宿主仓库和代理仓库

10、在maven中配置nexus
10.1
在maven项目的pom.xml文件中配置远程仓库(或者私服),maven默认的中央仓库id为central,如果重写,会直接覆盖。
依赖的远程仓库配置
| 1 2 3 4 5 6 7 8 9 | <repositories>  <repository>      <id>jboss</id>     <name>JBoss Repository</name>     <url>http://repository.jboss.com/maven2/</url>    <releases><enabled>true</enabled></releases>    <snapshots><enabled>false</enabled></snapshots>  </repository></repositories> | 

以及插件的远程仓库配置
| 1 2 3 4 5 6 7 8 9 | <pluginrepositories>  <pluginrepository>      <id>jboss</id>     <name>JBoss Repository</name>     <url>http://repository.jboss.com/maven2/</url>    <releases><enabled>true</enabled></releases>    <snapshots><enabled>false</enabled></snapshots>  </pluginrepository></pluginrepositories> | 
10.2 如果访问私服需要设置权限
则在maven的settings.xml中配置neuxs的用户名和密码
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | <!-- server     | Specifies the authentication information to use when connecting to a particular server, identified by     | a unique name within the system (referred to by the 'id' attribute below).     |      | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are      |       used together.     |    <server>      <id>deploymentRepo</id>      <username>repouser</username>      <password>repopwd</password>    </server></pre><br><br><h3>10.3将本地项目部署到远程仓库(或者私服),供团队其他成员使用</h3><p>编写完毕后,运行 mvn clean deploy 就会部署到私服</p><p><br></p><p></p><pre class="brush:java;"><distributionManagement>  <repository>    <id>id</id>    <name>name</name>    <url>http://localhost:8081/nexus/content/groups/public</url>  </repository>  <snapshotRepository>     <id></id>    <name></name>    <url>http://localhost:8081/nexus/content/groups/public</url></snapshotRepository></distributionManagement></pre><p></p><pre class="brush:java;"></pre><p></p><h3>10.4手动部署</h3><p><img src="/uploadfile/Collfiles/20161108/20161108093944265.png"alt="\"></p><p></p><h2>10.5maven在settings.xml文件中配置nexus</h2><p></p><pre class="brush:java;"> <profiles>  <!--配置mynexus-->    <profile>        <id>mynexus</id>        <repositories>                <repository>                    <id>public</id>                                                       <url>http://localhost:8081/nexus/content/groups/public/</url>                                          <releases>                        <enabled>true</enabled>                    </releases>                    <snapshots>                        <enabled>true</enabled>                    </snapshots>                </repository>            </repositories>                <pluginrepositories>                <pluginrepository>                  <id>public</id>                  <url>http://localhost:8081/nexus/content/groups/public/</url>                  <releases>                    <enabled>true</enabled>                  </releases>                  <snapshots>                    <enabled>false</enabled>                  </snapshots>                </pluginrepository>            </pluginrepositories>        </profile> | 
然后是激活我们的nexus配置,同样是在maven的settings.xml文件中
| 1 2 3 |     mynexus</activeprofile>    </activeprofiles> | 
10.6 如果仅仅是10.5,maven还是会去是不是的请求中央仓库
在settings.xml中增加如下配置即可使maven的所有的请求都被nexus拦截。
| 1 2 3 4 5 6 7 | <mirrors>     <mirror>        <id>mynexus</id>        <mirrorof>*</mirrorof>        <url>http://localhost:8081/nexus/content/groups/public/</url>     </mirror>  </mirrors> | 
11、一个实际maven项目的私服配置文件
11.1当安装好nexus后,运行console-nexus.bat
访问http://localhost:8081/nexus/
登陆
admin/admin123
之后选择Repositories
右边显示的7个仓库是nexus自带的,右边的链接是maven项目访问私服的具体链接

点击开 Public
Repositories,可以看到这个仓库组包含了其他仓库

11.2、我们的maven项目的配置文件会直接显示的表达出和其中的3个仓库(组)打交道
11.2.1
Repository的名字为 Public repositories,其作为替代maven中央仓库和其他仓库的和作为私服的对外接口,
其配置的位置位于
maven的settings.xml文件,尤其注意其id的值,不单在settings。xml中保持一致,在maven项目的pom.xml文件中的部署配置中
也要保持id值与之一致
(1)maven的settings.xml声明nexus的仓库组,这里id自定义为
mynexus
注意里面的url路径,是
http://localhost:8081/nexus/content/groups/public/
这是Public
repositories
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <profiles>  <!--配置mynexus-->    <profile>        <id>mynexus</id>        <repositories>                <repository>                    <id>public</id>                                                       <url>http://localhost:8081/nexus/content/groups/public/</url>                                          <releases>                        <enabled>true</enabled>                    </releases>                    <snapshots>                        <enabled>true</enabled>                    </snapshots>                </repository>            </repositories>                <pluginrepositories>                <pluginrepository>                  <id>public</id>                  <url>http://localhost:8081/nexus/content/groups/public/</url>                  <releases>                    <enabled>true</enabled>                  </releases>                  <snapshots>                    <enabled>false</enabled>                  </snapshots>                </pluginrepository>            </pluginrepositories>        </profile></profiles> | 
(2)maven的settings.xml激活仓库组,注意这里id自定义为
mynexus,与上面的声明一致
| 1 2 3 4 | <!--激活 mynexus-->        mynexus</activeprofile>     </activeprofiles> | 
(3)maven的settings.xml 声明的仓库组拦截一切maven的jar包请求(不再访问maven的默认的central即中央仓库)
注意这里id自定义为
mynexus,与上面的声明一致
| 1 2 3 4 5 6 7 | <mirrors>     <mirror>        <id>mynexus</id>        <mirrorof>*</mirrorof>        <url>http://localhost:8081/nexus/content/groups/public/</url>     </mirror>  </mirrors> | 
(4)这是权限,nexus有多种权限,其中用户名为admin的具有所有权限,默认密码为admin123
| 1 2 3 4 5 6 7 | <servers>    <server>       <id>mynexus</id>      <username>admin</username>      <password>admin123</password>    </server></servers> | 
11.2.2 Releases 是发布版本,当maven项目开发为稳定版本时,可以部署到这个仓库
11.2.3
Snapshots 是不稳定版本,如果上传可以选择上传到私服的这个仓库
11.2.4
决定上传时版本状态的是maven项目的pom.xml文件的标签

注意,不稳定版本有-SNAPSHOT后缀
11.2.5
maven的pom.xml部署到私服的配置
当项目需要部署到私服时,需要上传,在下面的配置文件之后,运行
mvn clean deploy命令即可
注意id为mynexus,和settings.xml文件中的一致
| 1 2 3 4 5 6 7 8 9 10 11 12 | <distributionmanagement>   <repository>     <id>mynexus</id>     <name>Releases</name>     <url>http://localhost:8081/nexus/content/repositories/releases/</url>   </repository> <snapshotrepository>   <id>mynexus</id>   <name>Snapshots</name>   <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotrepository></distributionmanagement>   | 
运行deploy命令后,我们可以到nexus的仓库中查看

是一个jar包了

而我的项目结构为

12
附属可能遇到的报错,这个是在eclipse中操作的,jdk1.7
window Maven私服搭建——nexus的更多相关文章
- maven私服搭建nexus/windows/linux(一)
		为什么要搭建nexus私服,原因很简单,有些公司都不提供外网给项目组人员,因此就不能使用maven访问远程的仓库地址,还有就是公司内部开发的一些版本的jar包,如果没有私服需要一人拷贝一份然后再自己安 ... 
- maven私服搭建nexus介绍(二)
		1.各个仓库介绍 Hosted:宿主仓库 主要放本公司开发的SNAPSHOTS测试版本,RELEASES正式发行版.合作公司第三方的jar包. Proxy:代理仓库 代理中央仓库:代理Apache下测 ... 
- Maven私服搭建(Nexus Repository Manager 3)
		下载和安装 下载地址:https://help.sonatype.com/repomanager3/download 注意:Nexus Repository Manager 3是一个Java服务器应用 ... 
- Linux安装配置maven以及搭建nexus私服(编写启动脚本)
		2011年07月12日16:32 下面介绍在Linux操作系统下安装配置maven和搭建nexus私服. 一.安装前的准备 下载 jdk http://www.oracle.com/technetw ... 
- maven私服搭建
		一.软件安装 地址:http://www.sonatype.org/nexus/thank-you-for-downloading/?dl=tgz 解压: 启动: >> nexus sta ... 
- maven私服搭建(centOS6.5)
		maven的好处和私服的应用本文不赘述,私服搭建如下: MAVEN 私服搭建(centOS 6.5 环境) 1. 准备环境,搭建centOS6.5系统环境,略 2. 准备对应的软件包如下: A. ... 
- maven仓库总结,maven私服搭建
		配置pom.xml依赖包时在这里找包的描述: http://search.maven.org/#browse 以java为根目录. mvn archtype:generate -DgroupId=zt ... 
- maven仓库总结,maven私服搭建,批量mvn eclipse:eclipse
		配置pom.xml依赖包时在这里找包的描述: http://search.maven.org/#browse 以java为根目录. mvn archtype:generate -DgroupId=zt ... 
- maven私服搭建&使用
		Maven私服搭建教程 一.nexus安装 1,解压安装包 安装包下载地址 2,以管理员身份打开cmd 3,进入到nexus的bin目录 (1) 安装:nexus install (2) 启动:nex ... 
随机推荐
- matplotlib-2D绘图库-面向对象
			个人理解:plt--画本 figure--产生画纸 子图 import numpy as np import matplotlib.pyplot as plt #解决能显示中文 plt.rcPa ... 
- nnet3的代码分析
			nnet3/nnet-common.h 定义了Index,(n, t, x)三元组,表示第n个batch中第t帧. 并声明了关于Index或Cindex的一些读写操作. nnet3/nnet- ... 
- 【vue】中 $parent 和 $children 的使用方法
			<div id="app"> A{{msg}} <my-button :msg="msg"></my-button> < ... 
- 安装LDAP用户认证
			LDAP伺服器设定 1.安装 openldap-servers yum -y install openldap openldap-devel openldap-servers 2.建立 LDAP 密码 ... 
- 源码解读-文件上传angularFileUpload1
			angular-file-upload 1.文件上传模块的引入就不赘述,简单准备 2.初始化组件并绑定change事件 3.监听用户选择文件FileItem(change事件),push进文件数组qu ... 
- 下载最新的glibc库并临时使用,而不污染原有系统环境
			以下参考了文中提到的博文,那篇博文其中有他安装时报错的内容,以及如何解决的,特别是报错2,值得学习借鉴 另外升级glibc,这篇文章有补充https://blog.csdn.net/fzuzhangh ... 
- pwnable.kr col
			collision - 3 pt 连接上查看col.c源码 分析一下代码, 1.hashcode等于一个固定的值 2.check_password函数取输入数据,4个一组,将输入的字符转成int,然后 ... 
- Django学习手册 - 基于requests API验证(二)
			原理分析: API接口验证 1.一个认证的key server端 和 client端都必须有这么一个认证key. 2.认证登录的时间限定 3.保存已验证的信息,在以后的验证不能再次登录 client ... 
- 为什么HTTPS比HTTP安全,以及两者的优缺点
			一.HTTPS简介 HTTPS协议的主要作用可以分为两种:一种是建立一个信息安全通道,来保证数据传输的安全:另一种就是确认网站的真实性. HTTP协议传输的数据都是未加密的,也就是明文的,因此使用HT ... 
- 阿里云IoT物联网平台入门教程
			参考链接:https://www.geek-workshop.com/thread-37883-1-1.html 
