1 解压
tar -zxvf nexus-3.19.1-01-unix.tar.gz
2 启动
cd /usr/local/nexus-3.19.1-01/bin
./nexus start
3 删除刚才的进程
4 新建账户
useradd nexus
chown -R nexus:nexus /usr/local/nexus-3.19.1-01/
5 切换用户
su nexus
cd /usr/local/nexus-3.19.1-01/bin
#启动
./nexus start
#查看是否启动
ps aux | grep nexus
6 查看日志
#命令
./nexus run
7 授权启动
#切换root
su root
#root用户
chown -R nexus:nexus /usr/local/sonatype-work/
#切换
su nexus
#启动
cd /usr/local/nexus-3.19.1-01/bin
#启动
nohup ./nexus run >nexus.log 2>&1 &
8 访问
http://192.168.38.45:8081/
9 设置密码
#查看默认密码,用默认密码登录会提示设置新的密码,我设置123456
cd /usr/local/sonatype-work/nexus3
10 登录成功
11 修改limit
#root 用户
su root
#新增
vim /etc/security/limits.conf
* hard nofile 65536
* soft nofile 65536
12 重启
#nexus 用户
su nexus
#启动
cd /usr/local/nexus-3.19.1-01/bin
nohup ./nexus restart >nexus.log 2>&1 &
13 Nexus 使用
13.1 修改阿里云代理
13.2 修改maven setting.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>F:\m2-springboot</localRepository>
<pluginGroups></pluginGroups>
<proxies></proxies>
<mirrors>
<!--配置私服,id与server rosh-admin 一致-->
<mirror>
<id>rosh-admin</id>
<mirrorOf>*</mirrorOf>
<name>Nexus Mirror</name>
<url>http://192.168.38.45:8081/repository/maven-public/</url>
</mirror>
<!--配置阿里云-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<servers>
<server>
<id>rosh-admin</id>
<username>admin</username>
<password>123456</password>
</server>
<!--快照-->
<server>
<id>rosh-releases</id>
<username>admin</username>
<password>123456</password>
</server>
<!--稳定-->
<server>
<id>rosh-snapshots</id>
<username>admin</username>
<password>123456</password>
</server>
</servers>
<profiles>
<profile>
<id>Deployment</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<!--私有仓库地址-->
<repositories>
<repository>
<id>Deployment</id>
<url>http://192.168.38.45:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<!--插件地址-->
<pluginRepositories>
<pluginRepository>
<id>Deployment</id>
<url>http://192.168.38.45:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!--激活-->
<activeProfiles>
<activeProfile>Deployment</activeProfile>
</activeProfiles>
</settings>
13.3 测试上传
(1)pom文件
<?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>org.example</groupId>
<artifactId>rosh-jar</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
</properties>
<distributionManagement>
<!--release-->
<repository>
<id>rosh-releases</id>
<name>Rosh Release Repository</name>
<url>http://192.168.38.45:8081/repository/maven-releases/</url>
</repository>
<!--快照-->
<snapshotRepository>
<id>rosh-snapshots</id>
<name>Rosh Snapshot Repository</name>
<url>http://192.168.38.45:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
(2)编写测试类
package com.rosh.hello;
public class NexusHello {
public void sayHello(){
System.out.printf("Hello Nexus");
}
}
(3) 上传
mvn deploy
13.4 测试下载
(1)pom
<dependencies>
<dependency>
<groupId>org.example</groupId>
<artifactId>rosh-jar</artifactId>
<version>1.0-20200823.130007-1</version>
</dependency>
</dependencies>
<distributionManagement>
<!--release-->
<repository>
<id>rosh-releases</id>
<name>Rosh Release Repository</name>
<url>http://192.168.38.45:8081/repository/maven-releases/</url>
</repository>
<!--快照-->
<snapshotRepository>
<id>rosh-snapshots</id>
<name>Rosh Snapshot Repository</name>
<url>http://192.168.38.45:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
(2) 测试类
package com.springboot;
import com.rosh.hello.NexusHello;
public class SpringBootWebTest {
public static void main(String[] args) {
NexusHello nexusHello=new NexusHello();
nexusHello.sayHello();
}
}
PS:安装包地址
链接:https://pan.baidu.com/s/1BtA6hkgXp-VYiUDE8rfsYA
提取码:in9w
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/15129.html