nexus安装

nexus下载

      wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.11.1-01-bundle.tar.gz
tar -xzvf nexus-2.11.1-01-bundle.tar.gz
mv nexus-2.11.1-01 /usr/local/nexus

设置环境变量

      export NEXUS_HOME=/usr/local/nexus/
export PATH=$PATH:$NEXUS_HOME/bin
export CLASSPATH=$CLASSPATH:$NEXUS_HOME/lib

设置服务自启动

      cp /usr/local/nexus/bin/nexus /etc/init.d
chkconfig --add nexus
chkconfig --levels 345 nexus on

设置/etc/init.d/nexus启动的相关参数

      NEXUS_HOME=/usr/local/nexus
RUN_AS_USER=nexus
PIDDIR="${NEXUS_HOME}"

设置java安装路径

nexus 目前版本要求的jdk版本是1.7以上。由于原来的服务器环境是1.6的版本,因此独立指定一个jdk1.7的安装路径。

      JAVA_HOME=/usr/java/jdk1.6.0_45
PATH=$JAVA_HOME/bin:$PATH

设置指定端口

在nexus/conf/nexus.properties文件中可以指定nexus的ip和端口

      application-port=8081
application-host=0.0.0.0

iptables开放8081端口

      -A INPUT -m state --state NEW -m tcp -p tcp --dport 8081 -j ACCEPT

保存,并重启iptables

配置日志路径

修改/usr/local/nexus/bin/jsw/conf/wrapper.conf中的日志路径

      wrapper.logfile=/home/logs/nexus/wrapper.log

配置仓库路径

解压nexus安装包后有nexus安装程序和sonatype-work两个目录。允许将sonatype-work放在任意位置,但是需要在nexus.properties中进行配置。

      nexus-work=/home/sonatype-work/nexus

nexus于nexus用户运行

      useradd nexus
#授权nexus安装目录的运行用户为nexus
chown nexus nexus nexus

nexus启动

      service nexus start

查看nexus运行日志

      tail -f /home/nexus/wrapper.log

界面访问

通过http://服务器ip:8081/nexus/可以直接在线操作仓库,默认的用户名密码是admin/admin123。

nexus仓库设置

定期下载索引,提高本地检索速度

Administration选项中找到Scheduled Tasks,在窗口页面点击Add

设置自动下载索引

对所有的代理仓库都设置为Download Remote indexes 为true.

设置仓库组

nexus默认有一个开放的仓库组,在Repositories列表中的第一个。它默认含有远程代理仓库central、本地发布仓库、第三方镜像仓库等四个仓库。

设置第三方仓库组

一张图说明一切

用户本地maven配置

修改maven的全局配置文件

设置构件磁盘存储位置

     <localRepository>F:\Svn\repository\maven</localRepository>

设置私有仓库服务器的访问权限

     <servers>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>

设置nexus为maven默认查看仓库

    <mirror>
<id>nexus</id>
<name>internal nexus repository</name>
<url>http://192.168.8.254:8081/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>

setting.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>F:\SvnCodeManage\repository\maven</localRepository>
<offline>false</offline>
<pluginGroups>
</pluginGroups> <proxies>
</proxies> <servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server> <server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers> <mirrors>
<!--使用nexus代理中央仓库-->
<mirror>
<id>nexus</id>
<name>internal nexus repository</name>
<url>http://192.168.8.254:8081/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror> <!--
<mirror>
<id>nexus-osc</id>
<mirrorOf>*</mirrorOf>
<name>Nexus osc</name>
<url>http://maven.oschina.net/content/groups/public/</url>
</mirror>
--> </mirrors> <profiles>
<profile>
<id>nexus-profile</id>
<repositories>
<repository>
<id>nexus-central</id>
<name>central</name>
<url>http://192.168.8.254:8081/nexus/content/groups/public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://192.168.8.254:8081/nexus/content/groups/public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus-profile</activeProfile>
</activeProfiles>
</settings>

发布项目中的构建部署到nexus仓库中

由于从项目中将构件发布到nexus需要登录权限,因此第一步需要设置登录权限。

第一步:在setting.xml设置鉴权

    <server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server> <server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>

第二步:在pom.xml中配置项目发布

<distributionManagement>  
    <repository>  
        <id>nexus-releases</id>  
        <name>Nexus Release Repository</name>  
        <url>http://192.168.8.254:8081/nexus/content/repositories/releases/</url>  
    </repository>  
    <snapshotRepository>  
        <id>nexus-snapshots</id>  
        <name>Nexus Snapshot Repository</name>  
        <url>http://192.168.8.254:8081/nexus/content/repositories/snapshots/</url>  
    </snapshotRepository>  
</distributionManagement>

上面的setting.xml中的配置id必须与pom.xml的配置id必须保持一致。

出现Remote Automatically Blocked and Unavailable

出现上述错误的原因是服务器不能访问外网网络,需要检查网络设置问题。更新索引需要一定的时间,如果没有更新完毕是无法搜索的。

使用nexus创建maven私有仓库的更多相关文章

  1. [maven] 使用Nexus创建maven私有仓库

    1.为什么需要maven私有仓库? 从Maven中央仓库下载所需的jar包,需要外网的支持.如果公司不能上外网的话则不能从中央仓库下载所需jar包,公司网速慢的时候也会影响项目构建的速度.用户可以用n ...

  2. 如何在云服务器创建maven私有仓库

    参考链接:https://blog.csdn.net/silence_jjj/article/details/77531916 nexus3创建maven私有仓库(windows) 1.官网:http ...

  3. 使用Nexus配置Maven私有仓库

    使用Nexus配置Maven私有仓库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.安装配置Nexus 1>.下载nexus 下载地址:https://www.sonat ...

  4. 架构实战项目心得(四):使用Nexus配置Maven私有仓库

    一.安装配置Nexus 1.  下载nexus https://www.sonatype.com/download-oss-sonatype 2.  解压:tar -zxfnexus-3.5.2-01 ...

  5. 如何使用GitHub创建Maven私有仓库

    [Github上创建仓库] 首先,在GitHub上创建自己的仓库(mvn-repo): [配置本地setting文件] 找到本地的maven settings文件,配置server: 有两种选择,可以 ...

  6. Nexus 搭建maven 私有仓库

    nexus如果没有私服,我们所需的所有构件都需要通过maven的中央仓库和第三方的Maven仓库下载到本地,而一个团队中的所有人都重复的从maven仓库下载构件无疑加大了仓库的负载和浪费了外网带宽,如 ...

  7. Nexus搭建Maven私有仓库

    原文:http://blog.csdn.net/rickyit/article/details/54927101 前言 Nexus Repository Manager is a Javaapplic ...

  8. 实战maven私有仓库三部曲之三:Docker下搭建maven私有仓库

    本章是<实战maven私有仓库>系列的第三篇,在前两章中,我们先在linux搭建maven私有仓库,然后在开发环境使用此仓库,本章我们在docker下快速搭建maven私有仓库,然后像前面 ...

  9. 安装Maven并搭建Maven私有仓库

    一.说明 Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具.我们在进行Java代码开发的时候,Eclipse+Maven+Jetty是一个十 ...

随机推荐

  1. phpstrom 与 xdebug 配合实现PHP单步调试

    不说废话,直接开始. 第一步: 安装并配置xdebug 安装 可以从官网直接下载对应php版本的xdebug,下载地址:  https://xdebug.org/download.php 配置,典型的 ...

  2. hadoop的wordcount例子运行

    可以通过一个简单的例子来说明MapReduce到底是什么: 我们要统计一个大文件中的各个单词出现的次数.由于文件太大.我们把这个文件切分成如果小文件,然后安排多个人去统计.这个过程就是”Map”.然后 ...

  3. Xcode工程中全局搜索汉字的方法

    打开”Find Navigator” 切换搜索模式到 “Find > Regular Expression” 输入@"[^"]*[\u4E00-\u9FA5]+[^" ...

  4. jQuery-单击文字或图片内容放大显示效果插件

    css很强大,jQuery也很强大,两者结合在一起就是无比强大.这里要介绍的这个单击文字或图片内容放大居中显示的效果就是这两者结合的产物. 先来介绍css和jQuery各自发挥了什么作用吧: css: ...

  5. 从头开始编写一个Orchard网上商店模块(6) - 创建购物车服务和控制器

    原文地址: http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-pa ...

  6. DOM(文本对象模型)简介

    DOM(文本对象模型)简介 在正式开始介绍jQuery处理XML前我们来了解一些必备的基础知识. DOM是HTML或者XML结构的一种展现形式,通过编程对DOM进行修改可以达到修改HTML/XML的目 ...

  7. [转]ASP.NET MVC 入门1、简介

    什么是MVC模式 MVC(Model-View-Controller,模型—视图—控制器模式)用于表示一种软件架构模式.它把软件系统分为三个基本部分:模型(Model),视图(View)和控制器(Co ...

  8. Linux内核系列设备模型(一) Kobject与Kset

    1.Kobject Kobject是设备驱动模型的核心结构,它使所有设备在底层都有统一的接口.在内核注册的kobject对象都会对应sysfs文件系统中的一个目录(目录名称有Kobject结构中k_n ...

  9. HW3.6

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  10. C#定义类成员

    1.成员定义 public--成员可以由任何代码访问. private--成员只能由类中的代码访问(如果没有使用任何关键字,就默认使用这个关键字). internal--成员只能由定义它的程序集(项目 ...