nexus搭建maven私服

下载nexus

首先,从以下地址下载nexus:

http://www.sonatype.com/download-oss-sonatype

选择下载nexus-2.13.0-01-bundle.tar.gz,适用于所有平台,本文将在linux系统下安装,操作系统信息如下:

Linux version 3.10.0-123.el7.x86_64 (mockbuild@x86-017.build.eng.bos.redhat.com) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Mon May 5 11:16:57 EDT 2014

注意nexus是基于Java开发的,这里之所以没去下载nexus-3.0.0-03-unix.tar.gz是因为它要求安装JDK8及以上,由于我的linux操作系统安装的jdk是7,所以选择nexus-2.13.0-01-bundle.tar.gz,否则出现如下错误:

No suitable Java Virtual Machine could be found on your system.
The version of the JVM must be at least 1.8 and at most 1.8.
Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.

启动nexus服务

将安装包拷贝到linux操作系统路径下,解压,然后cd到bin目录,可输入以下nexus命令:

Usage: ./nexus { console | start | stop | restart | status | dump }
./nexus start

注意,如果你是root账户,会出现如下错误:

****************************************
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.

原因已经提示的很清楚了,因为使用了root用户。解决方法很简单,换个其它用户即可;

或者设置环境变量export RUN_AS_USER=root,如下:

export RUN_AS_USER=root

启动nexus后,打印如下信息:

[root@localhost bin]# ./nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.

这里提个醒,一定要注意java的版本,以及8081端口是否被占用等

一切顺利的话,我们在浏览器输入http://10.0.10.53:8081/nexus/(这里10.0.10.53是nexus安装的服务器ip),即可访问nexus客户端,默认的用户名和密码:admin admin123

如下图:

 

上传jar包到nexus

首先是下载jar包,oracle的驱动包,由于Oracle授权问题,maven中央仓库没提供,我们自己下载,

http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html

然后按如下图进行操作:

在Artifact Upload页面,进行如下操作,具体就不细说了,见图:

弄完之后,我们可以在如下页面看到自己上传的jar包;

POM.XML配置

拷贝上图右下角的XML信息到pom.xml,即

<dependency>
  <groupId>com.oracle</groupId>
  <artifactId>ojdbc6</artifactId>
  <version>11.2.0.4.0</version>
</dependency>

另外配置下仓库信息,如下

    <repositories>  
        <repository>  
            <id>nexus</id>  
            <name>nexus</name>  
            <url>http://10.0.10.53:8081/nexus/content/groups/public/</url>  
            <releases>  
                <enabled>true</enabled>  
            </releases>  
            <snapshots>  
                <enabled>true</enabled>  
            </snapshots>  
        </repository>  
    </repositories>   
    <pluginRepositories>  
        <pluginRepository>  
            <id>nexus</id>  
            <name>nexus</name>  
            <url>http://10.0.10.53:8081/nexus/content/groups/public/</url>  
            <releases>  
                <enabled>true</enabled>  
            </releases>  
            <snapshots>  
                <enabled>true</enabled>  
            </snapshots>  
        </pluginRepository>  
    </pluginRepositories> 

想验证是否成功的话,可以查看maven日志,会发现从你的私服下载jar包

后续

关于nexus,还有很多其它功能没去尝试,这里只是简单的使用一下,后续有空可以深入研究。

 

SSH Secure Shell 3.2.9,

posted @ 2016-08-04 10:04  风一样的码农  阅读(11776)  评论(0编辑  收藏  举报