Ubuntu server下搭建Maven私服Nexus

简介:

Ubuntu server下搭建Maven私服Nexus

  Maven私服Nexus的作用,主要是为了节省资源,在内部作为maven开发资源共享服务器来使用。

  

  1、下载

  通过root用户进去Ubuntu server

  $  cd /opt

  $  wget http://download.sonatype.com/nexus/oss/nexus-2.10.0-02-bundle.tar.gz

  

  2、启动

  环境准备,启动nexus,必须先完成JDK环境的配置。

  $  cd /opt/

  $  tar -zxvf nexus-2.10.0-02-bundle.tar.gz

  $  cd /opt/nexus-2.10.0-02/bin

  $  vi nexus

  在启动文件nexus中增加nexus的启动用户,否则没权限启动,将报错如下:

  WARNING - NOT RECOMMENDED TO RUN AS ROOT

  If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script

  所以要解决此问题,需要在启动文件nexus,加上RUN_AS_USER=root,如图所示

  

  保存退出之后,即可启动nexus,命令如下:

  $  ./nexus start  

  Starting Nexus OSS...
Started Nexus OSS.

  表示启动成功,访问地址:http://ip:8081/nexus

 

  3、配置nexus

  登录nexus,右上角Log In,默认登录用户名密码:admin/admin123

  登录之后,我们可以点击左边菜单栏Repositories进入详细配置

  可以自己重新创建一个私服配置,这里我们用系统在带的Public Repositories

  

  关于仓库的类型介绍  

  hosted 类型的仓库,内部项目的发布仓库

  releases 内部的模块中release模块的发布仓库

  snapshots 发布内部的SNAPSHOT模块的仓库

  3rd party 第三方依赖的仓库,这个数据通常是由内部人员自行下载之后发布上去

  proxy 类型的仓库,从远程中央仓库中寻找数据的仓库

  group 类型的仓库,组仓库用来方便我们开发人员进行设置的仓库

 

  但是需要将其他几个代理的库配置映射到Public中,分别将Apache Snapshots、Central、Codehaus Sanpshots下Download Remote Indexes选项选择【true】,保存即可,默认是false,如下图

  

  把将类型为Proxy的库Apache Snapshots、Central、Codehaus Sanpshots配置到Public Repositories下,如下图:

  

  然后分别将Apache Snapshots、Central、Codehaus Sanpshots更新Index,在每一个库上面右键操作Repair Index

  

  最后将Public Repositories操作Repair Index

  然后接可以测试maven仓库了。

 

  4、远程测试maven仓库

  在项目中,引用maven仓库。则需要项目的pom.xml文件中添加如下:  

复制代码
<repositories>
    <repository>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>Public</id>
        <name>Public Repositories</name>
     <url>http://192.168.10.50:8081/nexus/content/groups/public/</url>
    </repository>
</repositories>                
复制代码

 

  然后执行maven下载依赖jar,检测是否下载成功~在私服上,通过左边的Artifact Search 搜索窗口,查看jar包是否在私服下载成功。

  另外,通常我们是修改本地的maven安装目录下的配置文件setting.xml,将本地仓库更换成私服仓库地址,保证本客户端上所有的项目都将使用私服,配置setting.xml如下:

  在<profiles></profiles>加入  

复制代码

  <profile>
<id>env-dev</id>
<repositories>
<repository>
<id>Public</id>
<name>Public Repositories</name>
<url>http://192.168.10.50:8081/nexus/content/groups/public</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>

复制代码

  并在</profiles>之后中加入  

<activeProfiles>
    <activeProfile>env-dev</activeProfile>        
</activeProfiles>

  新建项目,构建并测试

  

  5、三方jar包入maven私服

  比如 有些第三方jar包,在maven中心仓库没有,这个时候就需要手动在本地将jar上传上去,以供本地其他用户使用,简单截图介绍

  















本文转自一米一阳光博客园博客,原文链接:http://www.cnblogs.com/candle806/p/4076325.html ,如需转载请自行联系原作者

相关文章
|
1月前
|
Java Linux Maven
Linux系统Docker部署Nexus Maven并实现远程访问本地管理界面
Linux系统Docker部署Nexus Maven并实现远程访问本地管理界面
|
2月前
|
Java Linux Maven
私有仓库工具Nexus Maven如何部署并实现远程访问管理界面
私有仓库工具Nexus Maven如何部署并实现远程访问管理界面
57 0
|
6月前
|
Java 测试技术 Apache
【Maven】常用命令、插件管理、私服nexus
【Maven】常用命令、插件管理、私服nexus
|
6月前
|
Ubuntu 安全 Linux
百度搜索:蓝易云【Ubuntu 20.04 安装VNC Server的教程。】
请注意,VNC连接是以明文形式传输数据的,因此建议在安全的网络环境中使用VNC,并设置强密码以确保安全性。
191 1
|
5月前
|
存储 Java Maven
maven在尝试访问nexus存储库时得到“未授权” Not authorized , ReasonPhrase:Unauthorized
maven在尝试访问nexus存储库时得到“未授权” Not authorized , ReasonPhrase:Unauthorized
159 0
|
4月前
|
Java Maven 数据安全/隐私保护
Nexus【应用 01】上传jar包到私有Maven仓库的两种方法:手动 Upload 和 mvn deploy 命令(配置+操作流程)
Nexus【应用 01】上传jar包到私有Maven仓库的两种方法:手动 Upload 和 mvn deploy 命令(配置+操作流程)
363 0
|
5月前
|
存储 缓存 NoSQL
如何解决Ubuntu server 下 Redis安装报错:“You need tcl 8.5 or newer in order to run the Redis test”.
如何解决Ubuntu server 下 Redis安装报错:“You need tcl 8.5 or newer in order to run the Redis test”.
138 0
|
1月前
|
存储 Ubuntu 网络安全
|
1月前
|
存储 Java Maven
|
2月前
|
存储 Java Maven
从零开始使用Nexus搭建你的Maven私服(Windows系统)
作为开发人员,我们经常需要依赖于Maven来管理项目的依赖,但是在工作中可能会遇到网络不稳定、依赖库被删除等问题。为了解决这些问题,搭建一个Maven私服是一个理想的选择。本文将介绍如何在Windows系统环境下使用Nexus来搭建Maven私服。
161 0
从零开始使用Nexus搭建你的Maven私服(Windows系统)