码迷,mamicode.com
首页 > 系统相关 > 详细

【linux】【maven】maven及maven私服安装

时间:2019-09-19 14:26:59      阅读:368      评论:0      收藏:0      [点我收藏+]

标签:调用   密码   username   外部   osi   代理   def   epo   des   

系统环境:Centos7、jdk1.8

私服是一种特殊的远程仓库,它是架设在局域网内的仓库服务,私服代理广域网上的远程仓库,供局域网内的用户使用。当Maven需要下载构件的时候,它从私服请求,如果 私服上不存在该构件,则从外部远程仓库下载,缓存在私服上之后,再为Maven的下载请求提供服务。

一、安装maven 3.6.1

1. 下载maven

 1 # wget下载maven3.6.1
 2 [root@localhost home]#wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz20 
21 # 解压maven
22 [root@localhost home]# tar -zxvf apache-maven-3.6.1-bin.tar.gz 27 
28 # 重命名maven
29 [root@localhost home]# mv apache-maven-3.6.1 maven

2.设置maven环境变量

1 # 修改环境变量增加maven
2 [root@localhost home]# vi /etc/profile
3 
4     export MAVEN_HOME=/home/maven
5     export PATH=$MAVEN_HOME/bin:$PATH
6 
7 # 重载生效
8 [root@localhost home]# source /etc/profile

3.验证maven

1 [root@localhost home]# mvn -v
2 Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
3 Maven home: /home/maven
4 Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: /home/jdk/jre
5 Default locale: zh_CN, platform encoding: UTF-8
6 OS name: "linux", version: "3.10.0-957.27.2.el7.x86_64", arch: "amd64", family: "unix"

二、安装Nexus3.11.0 maven私服

1.下载

1 # wget下载nexus的tar包
2 [root@localhost home]# wget http://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-3.6.0-02-unix.tar.gz
3 
4 # 解压
5 [root@localhost home]# tar -C nexus -zxvf nexus-3.6.0-02-unix.tar.gz
1 [root@localhost home]# cd nexus
2 [root@localhost nexus]# ls
3 nexus-3.6.0-02  sonatype-work
4 [root@localhost nexus]# mv nexus-3.6.0-02/ nexus
5 
6 [root@localhost nexus]# ls -l
7 总用量 0
8 drwxr-xr-x. 9 root root 136 9月  19 13:11 nexus
9 drwxr-xr-x. 3 root root  20 9月  19 13:11 sonatype-work

2.修改nexus端口号

修改etc目录下nexus-default.properties文件

技术图片

 3.修改maven运行jvm

修改bin目录下的nexus.vmoptions文件

技术图片

 4.启动私服

1 [root@localhost bin]# pwd
2 /home/nexus/nexus/bin
3 [root@localhost bin]# ./nexus start
4 WARNING: ************************************************************
5 WARNING: Detected execution as "root" user.  This is NOT recommended!
6 WARNING: ************************************************************
7 Starting nexus

此处警告:可以useradd nexus,然后chown -R nexus:nexus /home/nexus 然后重启nexus解决

nexus start|stop|status|restart

5.浏览器打开http://192.168.8.10:8002/访问,默认密码admin/admin123。nexus启动很慢,耐心等待。

技术图片

技术图片

登录发现警告“System Requirement: max file descriptors [4096] likely too low, increase to at least [65536].”

解决: vi /etc/security/limits.conf

在文件末尾增加

*    soft nofile 65536
*    hard nofile 65536
*    soft nproc 4096
*    hard nproc 4096

重启nexus解决。

6.创建java仓库

技术图片

 技术图片

 这里选择 maven2(hosted)

技术图片

 maven配置:修改maven的settings.xml配置文件

  <!--nexus服务器-->
  <servers>  
    <server>  
        <id>nexus</id>  
        <username>admin</username>  
        <password>admin123</password>  
    </server>   
  </servers>  
  <!--组资源库的url地址  id和name自定义,mirrorOf的值设置为central,写死的-->  
  <mirrors>     
    <mirror>  
        <id>nexus</id>  
        <name>java</name>  
        <url>http://192.168.8.10:8002/repository/java/</url>  
        <mirrorOf>central</mirrorOf>  
    </mirror>  
   <mirror>  
        <id>alimaven</id>  
        <name>aliyun maven</name>  
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
        <mirrorOf>central</mirrorOf>  
    </mirror>
  </mirrors>  

 maven私服其他仓库建立及调用过程请参考:https://www.cnblogs.com/kongweifeng/p/9369936.html

 

【linux】【maven】maven及maven私服安装

标签:调用   密码   username   外部   osi   代理   def   epo   des   

原文地址:https://www.cnblogs.com/jxd283465/p/11548593.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!