1. 程式人生 > >LINUX安裝nexus私服與使用

LINUX安裝nexus私服與使用

下載nexus包並解壓

#本文下載版本2.14.3-02 筆者可更新至3.13.0-01
# wget "https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.3-02-bundle.tar.gz"
# tar xfvz nexus-2.14.3-02-bundle.tar.gz

這裡寫圖片描述

配置nexus環境變數

# cd /etc
# vi profile

i進入編輯模式,在檔案最下方加入環境變數配置

export RUN_AS_USER=root

export JAVA_HOME=/usr/local/software/jdk1.8.0
_161 //jdk目錄 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=.:$JAVA_HOME/bin:$RUN_AS_USER:$PATH

esc退出編輯模式,shift+z+z儲存退出

esc退出編輯模式,shift+z+z儲存退出

修改預設埠(8081)

# cd /usr/local/software/nexus/nexus-2.14.3-02/conf
# vi nexus.properties  //19行application-port=8081改為指定即可

請確保防火牆和伺服器規則以開放所配置介面

啟動nexus

# cd /usr/local/software/nexus/nexus-2.14.3-02/bin
# ./nexus start

nexus管理介面

本地MAVEN使用私服Nexus

對setting檔案進行配置

這裡寫圖片描述

<?xml version="1.0" encoding="UTF-8"?>     
<settings   xmlns="http://maven.apache.org/POM/4.0.0"    
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
    xsi:schemaLocation
="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>G:\singlecase\repository\</localRepository> <!--本地倉庫 --> <servers> <server> <id>sc</id> <username>admin</username> <!--私服使用者名稱 --> <password>admin123</password> </server> </servers> <profiles> <profile> <id>default</id> <repositories> <repository> <id>sc</id> <name>Public Repositories</name> <url>http://ip:port/nexus/content/repositories/releases/</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>sc</id> <name>Public Repositories</name> <url>http://ip:port/nexus/content/repositories/releases/</url> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>default</activeProfile> </activeProfiles> </settings>

pom檔案配置

<distributionManagement>
          <repository>
              <id>lh</id>
             <name>User Project Release</name>
              <url>http://ip:port/repository/maven-releases/</url>
          </repository>
  </distributionManagement>

將jar上傳至私服

這裡寫圖片描述

引用私服jar

<dependency>
            <groupId>xxx</groupId>
            <artifactId>model</artifactId>
            <version>LATEST</version>
    </dependency>