安装nexus
tar -zxvf xxxxxxx.tg
ls
nexus-2.11.2-03
sonatype-work
(一个 nexus 服务,一个私有库目录)
编辑 Nexus 的 nexus.properties 文件,配置端口和 work 目录信息(保留默认)
[root@localhost nexus]# cd nexus-2.11.2-03
[root@localhost nexus-2.11.2-03]# ls
bin conf lib LICENSE.txt logs nexus NOTICE.txt tmp
查看目录结构,jetty 运行
[root@localhost nexus-2.11.2-03]# cd conf
[root@localhost conf]# vi nexus.properties
# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus
# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF
第四步:编辑 nexus 脚本, 配置 RUN_AS_USER 参数
[root@localhost conf]# vi /usr/nexus/nexus-2.11.2-03/bin/nexus
NEXUS_HOME="…"
改为(不修改默认也可以):
NEXUS_HOME=“nexus安装目录”
#RUN_AS_USER=
改为:
RUN_AS_USER=root
启动ok 但是进不去的话可能hi防火墙的问题
开通防火墙端口
firewall-cmd --zone=public --add-port=8081/tcp --permanent
关闭防火墙
systemctl stop firewalld.service
默认用户名:admin
密码:admin123
访问http://ip地址:8081/nexus/
版本分为
central 私服中央仓库:把远程仓库的索引下载下来
releases版本为最终版本
snapshot为快照版本
上传jar 2种方式 自动/手动
自动
点击central 点击configuration修改选项为true
查看一下任务
如果下不来的话 那就对了,因为网络慢
修改pom.xml上传jar到nexus ***************************重点
<?xml version="1.0" encoding="UTF-8"?>
<project 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/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>meaven</groupId>
<artifactId>meaven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>meaven Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.54</version>
</dependency>
</dependencies>
<!--以下为修改添加代码 -->
<!--通过deploy上传 -->
<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.1.138:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.1.138:8081/nexus/content/repositories/releases/</url>
</snapshotRepository>
</distributionManagement>
<!-- 下载远程仓库的依赖-->
<repositories>
<repository>
<id>releases</id>
<url>http://192.168.1.138:8081/nexus/content/repositories/releases/</url>
</repository>
<repository>
<id>snapshots</id>
<url>http://192.168.1.138:8081/nexus/content/repositories/releases/</url>
</repository>
</repositories>
会根据 1.0-SNAPSHOT 或是 1.0-RELESESA 找到distributionManagement配置的具体上传路径上传
packaging一般为jar 如果是war的话需要配置tomcat在服务器运行
配置maven设置路径内的settings.xml
file>>settings
复制路径>>打开xml文件>>找到< server>标签
赋值注释内的server内容 添加用户信息按照上传库的名称(和pom.xml保持一致)…这样idea打包的jar包才能上传上去
点击deploy打包发布到maven管理>>>>>>>>>>>>上传完成
页面方式上传
从上到下依次点击选择上传
注意填写的auto guess内容要和pom.xml标签内容一致
已经可以使用了
也可以下载公共库的包
<!--下载库 -->
<repositories>
<repository>
<id>public</id>
<url>http://192.168.3.138:8081/nexus/content/groups/public/</url>
</repository>
</repositories>