CentOS 6.5搭建Nexus Maven私服

来源:互联网 发布:轮询算法 java 编辑:程序博客网 时间:2024/06/05 15:37

**

一、Nexus下载

**
下载地址:http://www.sonatype.org/nexus/go
我用的这个版本:nexus-2.14.3-02-bundle.tar.gz
**

二、Nexus解压与启动

**

1、解压 nexus-2.14.3-02-bundle.tar.gz

tar xvf nexus-2.14.3-02-bundle.tar.gz

2、解压完后生成2个目录:nexus-2.14.3-02和sonatype-work,前者包含了nexus的运行环境和应用程序,后者包含了你自己的配置和数据;

3、启动nexus

cd nexus-2.14.3-02/bin/./nexus start/stop/restart

**注意:nexus root启动异常:WARNING - NOT RECOMMENDED TO RUN AS ROOT
解决方案
修改%nexus_home%/bin/下的nexus
找到#RUN_AS_USER=改为RUN_AS_USER=root**
4. 访问网址:http://192.168.4.241:8081/nexus/ 看到Nexus欢迎页证明Nexus启动成功;
5. 右上角以admin登录,默认用户名/密码:admin/admin123。

**

三、Maven与Nexus私服配置

**

1、替换Maven默认配置文件(settings.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">    <servers>        <server>            <!-- id must be the same with pom.xml -->            <id>release</id>            <username>admin</username>            <password>******</password>        </server>        <server>            <!-- id must be the same with snapshotRepository section in pom.xml -->            <id>snapshot</id>            <!-- The username and password of the nexus server -->            <username>admin</username>            <password>******</password>        </server>    </servers>    <mirrors>        <mirror>            <id>nexus</id>            <mirrorOf>*</mirrorOf>            <url>http://192.168.4.241:8081/nexus/content/groups/public/</url>        </mirror>    </mirrors></settings>

2、本地上传依赖到Nexus服务器的两种方式: 通过网页上传和通过maven的方式depoly,在项目的pom.xml 加入如下配置:

<!-- For deploy your own maven jars -->  <distributionManagement>    <!-- Nexus Release Deploy Repository -->    <repository>      <id>release</id>      <name>Nexus release repository</name>      <url>http://192.168.4.241:8081/nexus/content/repositories/releases</url>    </repository>    <!-- snapshot repository -->    <snapshotRepository>      <id>snapshot</id>      <name>Nexus Snapshot Deploy Repository</name>      <url>http://192.168.4.241:8081/nexus/content/repositories/snapshots</url>    </snapshotRepository>  </distributionManagement>

注意:此处id应与settings.xml里面的id一致


到此配置完成,可以在本地引入依赖,看私服是否生成相应jar包

0 0
原创粉丝点击