最近我从北京离职来到上海,进入一家新公司,发现这家公司的项目很糟糕,不仅代码写的很随意(可能是这个项目原来是一个人写的原因的吧,不多吐槽别人的代码风格),而且项目竟然是半maven工程,一些公司内部的jar是直接在项目中引用的,我接到这个项目的时候内心是懵逼的,整了整整一天才把这个项目跑起来,十分的蛋疼。今天终于有时间将项目改造一下,尝试搭建一台maven私服,将内部jar包扔到私服上去,方便开发,后期项目改造的服务化jar包也将扔到私服上去
1,准备工作
操作系统:centos7.0
nexus:nexus-2.14.8-01-bundle
首先直接去nexus官网下载软件包,地址:https://www.sonatype.com/download-oss-sonatype
进入官网之后,拉到最下面:
点击下载tar.gz版本,我这里直接给出地址:
https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/oss/nexus-2.14.8-01-bundle.tar.gz
在centos上,用wget命令将安装包下载下来:
wget https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/oss/nexus-2.14.8-01-bundle.tar.gz
下载完了之后,解压:
tar -zxvf nexus-2.14.8-01-bundle.tar.gz
得到如下两个文件夹:
进入nexus-2.14.8-01/bin目录:
执行命令:
[root@VM_14_191_centos bin]# ./nexus Usage: ./nexus { console | start | stop | restart | status | dump } [root@VM_14_191_centos bin]# ./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.
发现启动的时候提示需要添加:RUN_AS_USER=root 到环境变量
编辑/etc/profile文件,在文件最后追加:export RUN_AS_USER=root
然后:source profile然配置生效
[root@VM_14_191_centos bin]# vim /etc/profile 这里在profile末尾追加export RUN_AS_USER=root... [root@VM_14_191_centos bin]# source /etc/profile [root@VM_14_191_centos bin]# echo $RUN_AS_USER root
然后再次启动:
[root@VM_14_191_centos bin]# ./nexus start **************************************** WARNING - NOT RECOMMENDED TO RUN AS ROOT **************************************** Starting Nexus OSS... Started Nexus OSS. [root@VM_14_191_centos bin]# ./nexus status **************************************** WARNING - NOT RECOMMENDED TO RUN AS ROOT **************************************** Nexus OSS is running (5029).
查看启动日志:
tail -f ../logs/wrapper.log
nexus的启动默认端口号是:8081(可以通过conf目录下nexus.properties文件修改),启动完毕之后浏览器访问:http://ip:8081/nexus
点击右上角登录,默认用户名:admin 密码:admin123