使用Nexus配置Maven私有仓库

下载并且安装nexus

1.从以下网址【https://www.sonatype.com/oss-thank-you-tar.gz】下载对应的版本,我下载的是linux版本的。**

解决到安装目录,我安装的是 /usr/local ;解压命令: tar -zxf nexus-3.12.1-01-unix.tar.gz
注意要先安装JDK8,nexus3.x支持的jdk版本最低是1.8.
检查下jdk的安装版本:

[root@www ~]# java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) Client VM (build 25.60-b23, mixed mode)
[root@www ~]# 

2.进入到bin目录,执行./nexus run &,出现如下界面启动成功,启动时需要一定的时间。

2018-07-20 03:20:20,689+0800 INFO  [jetty-main-1] *SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - 
-------------------------------------------------

Started Sonatype Nexus OSS 3.12.1-01

-------------------------------------------------
2018-07-20 03:20:22,350+0800 INFO  [qtp28871576-45] *UNKNOWN org.apache.shiro.session.mgt.AbstractValidatingSessionManager - Enabling session validation scheduler...
2018-07-20 03:20:22,396+0800 INFO  [qtp28871576-45] *UNKNOWN org.sonatype.nexus.internal.security.anonymous.AnonymousManagerImpl - Using default configuration: AnonymousConfiguration{enabled=true, userId='anonymous', realmName='NexusAuthorizingRealm'}
2018-07-20 03:20:23,152+0800 INFO  [qtp28871576-171] *UNKNOWN com.sonatype.nexus.analytics.internal.EventSubmitterImpl - Service URL: https://analytics.sonatype.com

3.访问http://192.168.0.50:8081/ 可以登录

这里写图片描述

默认端口号:8081
默认账号:admin
默认密码:admin123

4.修改配置

4.1、修改运行nexus3所使用的用户:
   [root@www bin]# vi nexus.rc
   run_as_user=”root”
4.2、修改nexus3启动所使用的jdk版本
   [root@www bin]#vi nexus
          INSTALL4J_JAVA_HOME_OVERRIDE=/usr/program/software/java8
4.3、修改nexus3默认端口
    [root@www bin]# vi nexus-default.properties
           application-port=8282
4.4、修改nexus3数据以及相关日志的存储位置
           [root@www bin]# vi nexus.vmoptions 
    -XX:LogFile=./sonatype-work/nexus3/log/jvm.log
    -Dkaraf.data=./sonatype-work/nexus3
    -Djava.io.tmpdir=./sonatype-work/nexus3/tmp

调整setting.xml的配置

1.配置server
  <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>

2.配置mirror
        <mirror>     
            <id>nexus-releases</id>     
            <mirrorOf>*</mirrorOf>     
            <url>http://192.168.0.50:8081/repository/maven-public/</url>     
        </mirror>    
        <mirror>     
            <id>nexus-snapshots</id>     
            <mirrorOf>*</mirrorOf>     
            <url>http://192.168.0.50:8081/repository/maven-snapshots/</url>     
        </mirror>


   <!-- 国内远程仓库:阿里云镜像 -->
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>

3.配置profile:
    <profile>    
      <id>nexus</id>    
      <repositories>    
        <repository>    
          <id>nexus-releases</id>    
          <url>http://nexus-releases</url>    
          <releases><enabled>true</enabled></releases>    
          <snapshots><enabled>true</enabled></snapshots>    
        </repository>    
        <repository>    
          <id>nexus-snapshots</id>    
          <url>http://nexus-snapshots</url>    
          <releases><enabled>true</enabled></releases>    
          <snapshots><enabled>true</enabled></snapshots>    
        </repository>    
      </repositories>    
      <pluginRepositories>    
         <pluginRepository>    
                <id>nexus-releases</id>    
                 <url>http://nexus-releases</url>    
                 <releases><enabled>true</enabled></releases>    
                 <snapshots><enabled>true</enabled></snapshots>    
               </pluginRepository>    
               <pluginRepository>    
                 <id>nexus-snapshots</id>    
                  <url>http://nexus-snapshots</url>    
                <releases><enabled>true</enabled></releases>    
                 <snapshots><enabled>true</enabled></snapshots>    
             </pluginRepository>    
         </pluginRepositories>    
    </profile>  

4.使用profile

     <activeProfiles>    
      <activeProfile>nexus</activeProfile>    
    </activeProfiles>

测试上传jar包到私服服务器

  • 在父pom中配置私服服务器地址
     <distributionManagement>
        <repository>
            <id>nexus-releases</id>
            <url>
               http://192.168.0.50:8081/repository/maven-public/
            </url>
        </repository>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <url>
                http://192.168.0.50:8081/repository/maven-snapshots/
            </url>
        </snapshotRepository>
    </distributionManagement>
  • 开始上传jar包
    这里写图片描述

注:其他如果是其他用户的话, 没有部署的权限;需要对应的授权,部署授权的步骤如下:

这里写图片描述
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值