zoukankan      html  css  js  c++  java
  • maven私仓搭建——nexus3

    maven私仓搭建——nexus3
    本文主要介绍maven私仓在windows下的搭建。
    本文主要参考:http://www.cnblogs.com/bingyeh/p/5913486.html
    好,下面上货。
    1、下载nexus3==>https://www.sonatype.com/download-oss-sonatype。

    下载windows版本。

    2、解压到本地的任意文件夹下。


    然后进入nexus-3.3.2-02in文件夹下。
    在当前文件夹下开启命令行,执行如下命令:
    nexus intall

    然后进入windows的服务管理页面,能够看到nexus已经成为系统服务了。


    使用命令nexus start 启动服务。使用命令 nexus stop 结束服务。

    3、进入nexus页面:
    http://localhost:8081/

    4、使用管理员用户登录:
    用户名:admin
    密码:admin123

    5、进入后新建仓库:


    这里需要解释一下我们需要的仓库类型。
    我们需要一个代理仓库从网上下载安装包,需要一个release仓库保存已经发布的上线的安装包,还需要一个snapshot用来保存快照的私仓。
    最后,这些私仓需要一个统一的访问入口,就是私仓组。

    6、分别看一下这几个私仓的配置:
    proxy私仓,使用的外部私仓是阿里的仓库http://maven.aliyun.com/nexus/content/groups/public:

    release私仓:


    snapshot私仓:

    group私仓组:

    7、如何在项目中使用。

    首先需要使用自定义的settings文件,并且在项目中使用新的maven配置。

     1     <?xml version="1.0" encoding="UTF-8"?>
     2     <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
     3               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     4               xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
     5         <!-- localRepository
     6        | The path to the local repository maven will use to store artifacts.
     7        |
     8        | Default: ${user.home}/.m2/repository
     9       <localRepository>/path/to/local/repo</localRepository>
    10       -->
    11      
    12         <!-- pluginGroups
    13        | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
    14        | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
    15        | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
    16        |-->
    17         <pluginGroups>
    18             <pluginGroup>org.sonatype.plugins</pluginGroup>
    19         </pluginGroups>
    20      
    21         <proxies>
    22         </proxies>
    23      
    24         <servers>
    25             <server>
    26                 <id>nexus</id>
    27                 <username>admin</username>
    28                 <password>admin123</password>
    29             </server>
    30         </servers>
    31      
    32         <mirrors>
    33      
    34             <mirror>
    35                 <id>nexus</id>
    36                 <mirrorOf>*</mirrorOf>
    37                 <url>http://192.168.0.120:8081/repository/nexus-public/</url>
    38             </mirror>
    39         </mirrors>
    40      
    41         <profiles>
    42             <profile>
    43                 <id>nexus</id>
    44                 <repositories>
    45                     <repository>
    46                         <id>central</id>
    47                         <url>http://central</url>
    48                         <releases><enabled>true</enabled></releases>
    49                         <snapshots><enabled>true</enabled></snapshots>
    50                     </repository>
    51                 </repositories>
    52                 <pluginRepositories>
    53                     <pluginRepository>
    54                         <id>central</id>
    55                         <url>http://central</url>
    56                         <releases><enabled>true</enabled></releases>
    57                         <snapshots><enabled>true</enabled></snapshots>
    58                     </pluginRepository>
    59                 </pluginRepositories>
    60             </profile>
    61      
    62         </profiles>
    63         <activeProfiles>
    64             <activeProfile>nexus</activeProfile>
    65         </activeProfiles>
    66     </settings>


    然后,还需要在pom文件中指定要上传的私仓名称,在pom文件最后添加如下内容。

      

     1 <distributionManagement>
     2             <repository>
     3                 <id>nexus</id>
     4                 <name>Releases</name>
     5                 <url>http://192.168.0.120:8081/repository/nexus-releases</url>
     6             </repository>
     7             <snapshotRepository>
     8                 <id>nexus</id>
     9                 <name>Snapshot</name>
    10                 <url>http://192.168.0.120:8081/repository/nexus-snapshots</url>
    11             </snapshotRepository>
    12         </distributionManagement>



    这样,在使用mavendeploy上传jar包的时候,就能够根据当前的版本上传到release或者snapshot上了。

    8、查看私仓是否上传成功。



    然后就可以到那个仓库下寻找你要找的,刚刚生成的jar 包。

  • 相关阅读:
    ASP.NET中JSON的序列化和反序列化
    Git 本地项目上传至托管平台(OsChina/GitHub)
    Android Gradle 完整指南(转)
    开发错误记录13:java.lang.UnsatisfiedLinkError: Couldn't load xxx.so: findLibrary returned null
    Android其它新控件 (转)
    一个Activity掌握Design新控件 (转)
    一个Activity掌握Android5.0新控件 (转)
    一个Activity掌握Android4.0新控件 (转)
    开发错误日记 12: Unsupported major.minor version 52.0
    Linux 下各个目录的作用及内容
  • 原文地址:https://www.cnblogs.com/zjm-1/p/10099525.html
Copyright © 2011-2022 走看看