最近公司想搭建maven仓库,所以就学习了一下,总结了这篇文章,需要的同学可以借鉴一下
linux搭建maven私服仓库
linux安装maven
-
先解压maven的压缩包apache-maven-apache-maven-3.6.1-bin.tar.gz 命令: tar -zavf pache-maven-apache-maven-3.6.1-bin.tar.gz
- maven下载地址:http://maven.apache.org/download.cgi
-
然后编辑linux的环境变量属性:
-
vim etc/profile
export M2_HOME=/home/maven/apache-maven-3.6.1 //你maven的解压目录
export path=$M2_HOME/bin:
-
配置中央仓库的镜像
-
打开安装好的maven中的settings.xml文件
-
vim /home/maven/apache-maven-3.5.4/conf/settings.xml
-
在标签下加入仓库配置的信息
-
<mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror>
-
-
-
在Linux搭建Nexus私服
-
使用xftp将下载好的nexus-2.14.0-01-bundle.tar.gz 压缩包上传到linux中
下载地址:https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.2-01-bundle.zip
如果下载不下来,可以下载百度的:
https://pan.baidu.com/s/1mgznhd2?errno=0&errmsg=Auth Login Sucess&&bduss=&ssnerror=0&traceid=
-
tar -zxvf nexus-2.14.0-01-bundle.tar.gz 解压后出现两个文件夹
-
nexus-2.14.0-01 主要用到这个文件夹
sonatype-work 保存所有配置文件的信息(不用动)
-
-
启动nexus
- 进入 cd /home/nexus/nexus-2.14.0-01/bin/nexus
-
./nexus start
-
如果启动报错
**************************************** 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用户,需要配置一下:
进入 cd /home/nexus-2.11.4-01/bin
vim nexus
命令模式下搜索 RUN
把#RUN_AS_USER= 改成RUN_AS_USER=root
-
-
启动成功
**************************************** WARNING - NOT RECOMMENDED TO RUN AS ROOT **************************************** Starting Nexus OSS... Started Nexus OSS.
-
- 进入 cd /home/nexus/nexus-2.14.0-01/bin/nexus
-
启动后 默认端口8081可以去访问 http://IP地址:8081/nexus/
-
将所有proxy中的下载配置打开(右键 proxy 选择Repair index)
-
-
将所有proxy中的下载配置打开(右键 proxy 选择Repair index)
Public Repositories 对应的地址 http://IP地址:8081/nexus/content/groups/public/ 我们的仓库地址
-
最后: 在setting.xml配置私服的引用(是我们开发环境 maven的setting.xml文件)
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR C