Maven私服搭建Nexus Sonatype(四)
来源:互联网 发布:蜂群算法代码 编辑:程序博客网 时间:2024/06/05 02:23
Nexus Sonatype下载安装
Nexus Sonatype官方地址link
安装完毕后,还需配置下环境变量,path里追加:
如:path: E:\software\nexus-3.0.1-01\bin;
版本:2.x.x
- 以管理员身份打开cmd命令行,输入nexus会看到
nexus {console : start : stop : restart: install : uninstall } - 输入nexus install 安装(可以在service中看到)
- nextus start启动
- nextus stop停止
浏览器打开 http://localhost:8081/nexus/
注:默认端口号为8081,可以通过配置文件修改:E:\software\nexus-2.12.0-01\conf\nexus.properties里的application-port=8081
- 以管理员身份打开cmd命令行,输入nexus会看到
版本:3.x.x
- cmd行输入 nexus /run (等几分钟,直到出现 Satarted Sonatype Nexus OSS 3.x)
浏览器打开 http://localhost:8081/
注:默认端口号为8081,可以通过配置文件修改:E:\software\nexus-3.0.1-01\etc\org.sonatype.nexus.cfg里的 application-port=8081
默认:用户名admin,密码admin123
推荐一篇网上博客:网上博客link
Nexus 的仓库与仓库组
类型四类:代理仓库proxy,宿主仓库hosted,仓库组group,虚拟viartual
格式二种:maven2和maven1
策略policy:发布版release和快照版snapshot
对应关系如下:
上面介绍的博客上有【添加代理仓库】、【构件搜索】等介绍:link,这就不多说了。
配置Maven从私服Nexus下载构件
Pom.xml里配置
<!--从Nexus下载构件 --><repositories> <repository> <id>nexus</id> <name>nexus</name> <url>http://localhost:8081/nexus/content/groups/public/</url> <releases> <!-- defaulttrue --> <enabled>true</enabled> </releases> <snapshots> <!-- default false --> <enabled>true</enabled> </snapshots> </repository></repositories>
说明:这样配置,只对当前项目有效,如果换了其他的项目,那就还需要写下这个配置,很麻烦,那么有没有只要配置一次,本机每个项目都能这样了。那么我们就想到了Maven里的settings.xml配置文件了。但是,setting里没有提供<repository>标签配置。而是使用了<profiles>来配置。
settings.xml里配置
</profiles> .... <profile> <id>nexus</id> <repositories> <repository> <id>nexus</id> <name>nexus</name> <url>http://localhost:8081/nexus/content/groups/public/</url> <releases> <!-- 默认true --> <enabled>true</enabled> </releases> <snapshots> <!-- 默认false --> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> </profiles>
一个<profile>就相当有于一个私服,所有这儿可以配置多个。但是都不会生效的。还需要配置一个<activeProfiles>来指定那个profile生效。
<activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles>
这时候,虽然所有项目都从Nexus中下载了,当时我们还会发现,没有的构件还会去中央仓库中去下载,如果希望只从私服Nexus中下载,没有的话,本机也不用去中央仓库下,我们可以在<mirrors>中配置。
</mirrors> <mirror> <id>nexus</id> <mirrorOf>*</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://localhost:8081/nexus/content/groups/public/</url> </mirror></mirrors>
部署构件至Nexus
Maven部署配置
pom.xml
<distributionManagement> <!-- release --> <repository> <id>nexus-release</id> <name>Nexus Release Repository</name> <url>http://localhost:8081/nexus/content/repositories/releases/</url> </repository> <!-- snapshot --> <snapshotRepository> <id>nexus-snapshot</id> <name>Nexus snapshot Repository</name> <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository></distributionManagement>
settings.xml中还需要对Nexus登录的用户和密码进行配置
<settings> ... <servers> <server> <id>nexus-release</id> <username>admin</username> <password>amdmin123</password> </server> <server> <id>nexus-snapshot</id> <username>admin</username> <password>amdmin123</password> </server> </servers> ...</settings>
手动部署到第三方构件至Nexus
选择3rd party的宿主仓库,然后选择Artifact Upload选项,如果该构件是Maven构件的,那么GAV definition下拉菜单就选From POM,否则就选GAV Parameters.
点击Select Artifact(s) to Upload从本地选择你要上传的构件,然后单击Add Artifact按钮。Nexus允许用户一次上传一个主构件和多个附属构件(Classifier),最后点Upload Artifact(s) 按钮将构件上传到仓库。
Nexus权限管理
Nexus默认预定义了3个用户,三个用户对应三个权限:
- admin:对nexus完全掌控,默认密码是admin123
- deployment:可以查阅,搜索,部署,不能对nexus进行任何配置。默认密码deployment123
- anonymous:匿名用户,无法登录。
※管理admin用户可以添加用户(admin登录进去⇒找到左侧栏User选项卡⇒add User ⇒…略…)
为项目分配独立的仓库
建自己项目的releases和snapshots的hosted仓库(假设名字叫CMDsnapshots,后面所有步骤只以snapshots为例,releases同样的步骤)。(admin权限登录⇒左侧repositories选项卡⇒add下拉菜单,选择hosted repository⇒输入id,name..略…)
设置权限(通过repository Targets可以看出,其实就是*匹配的表达式),需要几个步骤:权限Privileges、角色Roles、用户Users共三个步骤来设定
a)权限: admin权限登录 ⇒ 左侧Privileges选项卡 ⇒ add下拉菜单,选择repository target Privilege ⇒ 各个域填值Name(CMD_priv_snap);Description(CMD_priv_snap);Repository(CMDsnapshots上面步骤一的对应仓库名);Repository Target(ALL,maven2) ⇒ 保存 这样就会看到增删查改对应的权限xxxx(create),xxxx(delete),xxxx(read),xxxx(update)。b)角色: admin权限登录 ⇒ 左侧Roles选项卡 ⇒ add下拉菜单,选择Nexus Role ⇒ 各个域填值Role Id(CMD_role_snap);Name(CMD_role_snap);Description(CMD_role_snap);Role/Privilege Management (选择add,将步骤a产生的权限,选择全部添加进来) ⇒ 保存c)用户: admin权限登录 ⇒ 左侧Users选项卡 ⇒ add下拉菜单,选择Nexus User ⇒ User ID;First Name;First Name;LastName;Email;Status(Active生效);RoleMangement (选择add,将步骤b产生的角色,选择全部添加进来) ⇒ 保存
Nexus调度任务
Nexus提供了一系列可配置的调度任务来方便用户管理系统。用户可以设定这些任务运行的方式,例如每天、每周等。调度任务会在适当的时候在后台运行。
打开步骤:左侧栏Scheduled Tasks选项 ⇒ add ⇒...
有多个种类。
总结:主要讲了Nexus的安装,Nexus的仓库和组,Nexus的配置,Nexus的权限,怎样给每个项目建立自己的仓库并分配权限。最后还介绍了下,Nexus的调度任务。
- Maven私服搭建Nexus Sonatype(四)
- 搭建maven + nexus(sonatype)
- sonatype nexus 搭建maven服务器
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- Sonatype Nexus 搭建Maven 私服
- 总结oninput、onchange与onpropertychange事件的用法和区别
- 基于amoeba实现MySQL读写分离
- 翼发云赵裁:打造企业服务SaaS精品
- 蓝牙CC2541的串口通讯
- android 版本更新的应用
- Maven私服搭建Nexus Sonatype(四)
- ndk 独立(standalone)交叉编译环境搭建
- HDU1013——Digital Roots
- An invalid domain [.test.com] was specified for this cookie 原因分析
- 封装数据库操作
- DrySister看妹子应用(第一版)——1.项目搭建与简单实现
- zzuli 1895 985的0-1串难题
- ubuntu16.04安装后开发人员应该做的几件事儿
- Codeforces Round #365 (Div. 2)