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管理界面

访问地址:http://ip:port/nexus
LINUX安装nexus私服与使用_第1张图片

本地MAVEN使用私服Nexus

对setting文件进行配置

LINUX安装nexus私服与使用_第2张图片

     
<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>scid>
    <username>adminusername>        
    <password>admin123password>
    server>
    servers>
     <profiles>
        <profile>
            <id>defaultid>
    <repositories>
    <repository>
          <id>scid>
          <name>Public Repositoriesname>
          <url>http://ip:port/nexus/content/repositories/releases/url>
      repository>
    repositories>
    <pluginRepositories>
      <pluginRepository>
         <id>scid>
         <name>Public Repositoriesname>
         <url>http://ip:port/nexus/content/repositories/releases/url>
     pluginRepository>
 pluginRepositories>
 profile>
 profiles>
 <activeProfiles>
    <activeProfile>defaultactiveProfile>
  activeProfiles>
settings>  

pom文件配置

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

将jar上传至私服

LINUX安装nexus私服与使用_第3张图片

引用私服jar

<dependency>
            <groupId>xxxgroupId>
            <artifactId>modelartifactId>
            <version>LATESTversion>
    dependency>

你可能感兴趣的:(Maven,Linux,Nexus)