zoukankan      html  css  js  c++  java
  • 使用nexus搭建maven私服

      在日常开发中我们会经常使用的第三方jar包,而我们对jar包的管理往往是使用maven去做管理,但是有时候我们发现使用到的一些jar在阿里的中央仓库是找不到的,而且就算找到,下载速度也不尽人意,所以我们一般在公司都会去搭建自己的私服,去存放我们开发所需要的jar包。下面我就在自己的云服务器上搭建一个私服。

    一、下载 nexus

      下载地址:https://help.sonatype.com/repomanager2/download/download-archives---repository-manager-oss
      我这里使用的是 nexus-2.14.9-01

    二、安装 nexus

      在自己服务器找到合适的位置,将刚刚下载的包进行解压。解压后出现2个文件夹 nexus-2.14.9-01 和 sonatype-work

    三、修改端口

      nexus 的配置文件在nexus-2.14.9-01/conf 中,我们可以修改 nexus.properties 文件中的 application-port 端口来改变端口,这个端口默认为8081,这里我就不做修改了。

      由于我使用的是阿里云服务器,所以,我需要去阿里云服务器上配置防火墙端口的出入栈规则。

    四、修改启动脚本

      nexus 的启动脚本在nexus-2.14.9-01/bin 中 nexus ,其中有两个地方需要注意 NEXUS_HOME=".." 这个是修改安装目录,而此处是.. 可以不用修改,自动获取上级目录。 RUN_AS_USER=root 这个是启动的用户,这里一定要修改启动用户为root

    五、启动 nexus

      ./nexus start 启动 nexus .


      尝试浏览器访问 http://ip:port/nexus


      至此,我们的nexus就算搭建完成。

    六、添加用户

    这里我们首先需要登录,而登录的初始密码是 admin/admin123 
    这里我们可以通过右键用户去为用户修改密码。

      下面我们来新增一个用户。这里我为我的用户新增三个权限 分别是开发人员权限,所有仓库的查看权限,所有仓库的只读权限。

    七、新增 jar 包

      我们平时的jar包可以根据类型加入不同的类别中。

      下面在第三方地址下加入jar包

      查找刚刚加入的jar包

      最后附上我的maven私服的setting文件

    <?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>D:/dev/apache-maven-3.0.4/.m2/repository</localRepository>-->
        <interactiveMode>true</interactiveMode>
        <offline>false</offline>
        <pluginGroups>
            <pluginGroup>org.mortbay.jetty</pluginGroup>
            <pluginGroup>org.jenkins-ci.tools</pluginGroup>
        </pluginGroups>
        
        <!--配置权限,使用默认用户-->
        <servers>
            <server>
                <id>nexus-releases</id>
                <username>deployment</username>
                <password>deployment123</password>
            </server>
            <server> 
                <id>nexus-snapshots</id>
                <username>deployment</username>
                <password>deployment123</password>
            </server>
        </servers>
    
        <mirrors>
    
        </mirrors>
    
        <profiles>
            <profile>
               <id>dev</id>
                    <activation>
                        <activeByDefault>false</activeByDefault>
                        <jdk>1.6</jdk>
                    </activation>
                    <repositories>
                        <!-- 私有库地址-->
                        <repository>
                            <id>nexus</id>
                            <url>http://ip:port/nexus/content/groups/public/</url>
                            <releases>
                                <enabled>true</enabled>
                            </releases>
                            <snapshots>
                                <enabled>true</enabled>
                            </snapshots>
                        </repository>
                    </repositories>      
                    <pluginRepositories>
                        <!--插件库地址-->
                        <pluginRepository>
                            <id>nexus</id>
                            <url>http://ip:port/nexus/content/groups/public/</url>
                            <releases>
                                <enabled>true</enabled>
                            </releases>
                            <snapshots>
                                <enabled>true</enabled>
                           </snapshots>
                        </pluginRepository>
                    </pluginRepositories>
                </profile>
        </profiles>
        
        <!--激活profile-->
        <activeProfiles>
            <activeProfile>dev</activeProfile>
        </activeProfiles>
        
    </settings>

    -------------------- END ---------------------

    
    

    最后附上作者的微信公众号地址和博客地址 

    
    

    公众号:wuyouxin_gzh

    
    

    
    

     

    
    

    Herrt灬凌夜:https://www.cnblogs.com/wuyx/

     

  • 相关阅读:
    类的加载与ClassLoader的理解
    反射:获取Class 类的实例(四种方法)
    磁盘调度算法
    死锁检测算法
    银行家算法
    最低松弛度调度算法模拟
    多级反馈队列调度算法
    内存中:请求调页存储管理方式的模拟
    内存的动态分区分配方式的模拟
    “短进程优先”调度算法
  • 原文地址:https://www.cnblogs.com/wuyx/p/9977784.html
Copyright © 2011-2022 走看看