Nexus 安装运维手册
1. Nexus 安装与配置
1.1 下载Nexus
登录https://www.sonatype.com/download-oss-sonatype,下载最新的Nexus版本。 我这里使用的是nexus-3.16.1-02版本;
1.2 安装Nexus
#将tar包上传到服务器/usr/local/目录下解压,这个时候会出现 nexus-3.16.1-02、sonatype-work 两个文件夹 tar -zxvf nexus-3.16.1-02-unix.tar.gz #修改配置文件,eg:端口号 cd /usr/local/nexus-3.16.1-02/etc vim nexus-default.properties
1.3 启动Nexus
启动用户是root的时候会出现下面的警告,可以通过修改/usr/local/nexus-3.16.1-02/bin/nexus.rc文件解决;
#修改启动用户run_as_user,建议不要使用root vim /usr/local/nexus-3.16.1-02/bin/nexus.rc #
cd /usr/local/nexus-3.16.1-02/bin ./nexus start --后台启动 ./nexus run --前台启动,显示日志
1.4 登录Nexus
服务启动完以后,输入Ip地址+端口访问(8081),Nexus默认的账户名和密码是是 admin/admin123
1.5 配置私有库
将私有库添加到http://192.168.209.128:8081/repository/maven-public/中。
1.6 导入jar包
一般私服都是存在内网环境,Nexus3.0以后需要通过命令命令将具体的jar包打到私服中;
#将下面的脚本丢到需要上传jar包的文件目录下
chmod u+x mavenimport.sh
./mavenimport.sh -u admin -p admin123 -r http://192.168.209.128:8081/repository/lingan/
#!/bin/bash
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params while getopts ":r:u:p:" opt; do
case $opt in
r) REPO_URL="$OPTARG"
;;
u) USERNAME="$OPTARG"
;;
p) PASSWORD="$OPTARG"
;;
esac
done find . -type f -not -path './mavenimport\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml'
-not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;
1.7 设置登录用户权限
建议将admin注销,重新定义一个登录用户。在Nexus 3.0 这个版本中我直接删除admin会报错,但是设置为不可用没有问题;
2. Maven 安装与配置
2.1 下载Maven
登录http://maven.apache.org 下载最新的maven版本,我这里使用的是apache-maven-3.6.1版本。
2.2 安装Maven
将tar包上传到服务器/usr/local/目录下解压
tar -zxvf apache-maven-3.6.1-bin.tar.gz
2.3 配置Maven
#配置release、snapshot的用户信息;
#配置mirror指向私服的nexus-public;
vim /usr/local/maven/apache-maven-3.6.1/conf/setting.xml
3. 工作空间配置
3.1 修改本地Maven配置
配置release、snapshot的用户信息;
配置mirror指向私服的nexus-public;
3.2 修改工程中的pom文件
<repositories>
<repository>
<id>nexus-public</id>
<url>http://192.168.11.23:8180/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>release</id>
<url>http://192.168.11.23:8180/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshot</id>
<url>http://192.168.11.23:8180/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
</plugins>
</build>
最新文章
- 修改jetty的默认端口号
- oracle字符集相关问题
- PHP对自己I/O流访问的封装(转)
- 关于Javascript中的复制
- Html - Bootstrap 头部
- Strlen()与sizeof()
- NumPy基础:数组和矢量计算
- 浅析c++/java/c#三大热门编程语言的运行效率
- s2-048远程代码执行漏洞
- Socket 聊天工具
- 数据仓库中的Inmon与Kimball架构
- java反射之获取所有方法及其注解(包括实现的接口上的注解),获取各种标识符备忘
- 花了几天学习了vue跟做的仿制app
- JS 原型和闭包
- js中parseInt和Number
- 【c++】函数默认参数
- 【并发编程】使用BlockingQueue实现<;多生产者,多消费者>;
- JS location.href跳出框架打开新页面
- 用纯css实现下拉菜单的几种方式
- 转 update关联更新在sqlserver和oracle中的实现
热门文章
- 暑假提高组集训Day1 T2
- 三、JVM之方法区
- Unity SurfaceShader详解
- c#数字图像处理(六)直方图均衡化
- [CCPC2019 ONLINE]E huntian oy
- 【模板】普通平衡树(权值splay)
- Linux中inode详解
- 《Kubernetes权威指南》01_Kubernetes入门——Kubernetes 是什么
- 保存网页内容到excel
- The .native modifier for v-on is only valid on components but it was used on <;input>;