码迷,mamicode.com
首页 > 其他好文 > 详细

私服nexus 搭建配置

时间:2020-05-23 16:35:36      阅读:57      评论:0      收藏:0      [点我收藏+]

标签:image   jdk   inf   文件   阿里云   txt   项目   基本   basedir   

应用场景

java 一些公共依赖的包,一般都放在私服,供编译(例如maven)时去下载,如果没有私服那么一些公共的组件包就需要去中央仓库下载,而中央仓库是外网存在访问速率的问题,而且还需要外网开放权限。再有如果依赖的包仅仅是公司内部使用自己开发的,那么就只能放在私服供内网的内部使用,不然就得放在项目里面这显然不是一个好办法。私服的另一个功能可以控制访问权限决定谁能看到自己的依赖包。

安装 

首先是jdk 配置环境变量,然后官网下载tgz 压缩包解压即可。一般主流版本都是2.x

目录结构及配置介绍

解压后的目录有两个 nexus  sonatype-work

nexus   就是它的应用程序目录,也就是一个java项目的目录

[root@localhost nexus]# ls
bin                 启动程序所在 
conf                配置文件
lib                java 一些库文件
LICENSE.txt
logs               日志
nexus               web 应用配置所在
NOTICE.txt tmp

配置文件conf/nexus.properties

...  ...
# Jetty section application
-port=8081                     #web 服务对外端口 application-host=0.0.0.0                   #监听地址 nexus-webapp=${bundleBasedir}/nexus             #bundleBasedir 就是安装包解压后的 nexus目录,目录名字都有版本号,一般都会把名字改为nexus nexus-webapp-context-path=/nexus              #这类似于tomcat 中的context,也就是url里面后面的路径 # Nexus section nexus-work=${bundleBasedir}/../sonatype-work/nexus   #nexus 工作目录也就是仓库地址 runtime=${bundleBasedir}/nexus/WEB-INF          #提供web 服务的目录

sonatype-work  

就是工作目录,里面的nexus 其实就是仓库所在地

启动用户

一般都不用root 用户启动,创建一个普通用户例如nexus ,然后更改bin/nexus 里面的RUN_AS_USER=nexus ,更改nexus 相关目录所属组和主为nexus 。

启动服务

su -  nexus

../bin/nexus  start

 

web 界面管理使用

登陆 http://ip:8081/nexus

默认用户名密码:admin/admin123

用户管理

Security>Users

仓库

分类:group  hosted  proxy  virtual

group   可以通用管理hosted等仓库的访问
hosted  本地管理的,分为release
/ snapshot / 3rd-party
      release/snapshot 可以通过pom 上传依赖,3rd-party只能手动上传。
proxy   nexus 代理访问的,例如中央仓库或者阿里云仓库

virtual  基本上已经不再使用

代理仓库配置

技术图片

 手动上传包

技术图片

 

 

 pom 文件中配置

<repositories>
  <repository>
    <id>hfax</id>
    <name>hfax</name>
    <url>http://x.x.x.x:8081/nexus/content/groups/public/</url>
  </repository>
</repositories>

   
<distributionManagement>                      #下载私服里面的包时候需要如下配置 <repository> <id>release</id>                   #id 一般为maven 中server 配置的id,对应私服仓库的用户名和密码 <name>Nexus Release Repository</name> <url>http://x.x.x.x:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <name>Nexus Release Repository</name> <url>http://x.x.x.x:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>

group 仓库的管理

技术图片

 

私服nexus 搭建配置

标签:image   jdk   inf   文件   阿里云   txt   项目   基本   basedir   

原文地址:https://www.cnblogs.com/fanggege/p/12711326.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!