1.nexus
Nexus Repository Manager(通常简称 Nexus 或 Nexus RM)是由Sonatype公司开发的一款开源的、强大的软件仓库管理工具,主要用于企业级的二进制组件(如Java库、Node.js模块、Python包等)存储、管理和分发。
官方文档:https://help.sonatype.com/index.html?lang=en
2.安装
下载地址:https://help.sonatype.com/en/download.html
如果不能下载的话可以用百度网盘下载;
链接:https://pan.baidu.com/s/1zK3qnO47gfgn9MFxbrUrBA
提取码:6fiq
参考连接:https://blog.csdn.net/u012581020/article/details/130812447
笔者官方没有下载成功,源码打包ui报错也没有成功
将下载的包上传到服务器,执行命令:
#将nexus 解压到/usr/local/ 目录
tar -zxvf nexus-3.54.1-01-unix.tar.gz -C /usr/local/
#创建nexus用户
useradd nexus
#更改/usr/local/目录的所有者未nexus
chown -R nexus:nexus /usr/local/nexus-3.54.1-01
jdk安装
#搜索jdk
yum search openjdk
#安装需要的jdk版本
yum install java-1.8.0-openjdk.x86_64
#安装成功查看jdk版本
java -version
3.运行
查看系统要求:https://help.sonatype.com/en/sonatype-nexus-repository-system-requirements.html#instance-resource-sizing-profiles
#切换用户 nexus
su - nexus
#进入到安装目录
cd /usr/local/nexus-3.54.1-01
#后台启动 nexus相关命令:{start|stop|run|run-redirect|status|restart|force-reload}
./bin/nexus start
# 运行,关闭窗口程序停止运行,调试的时候使用
./bin/nexus run
#停止
./bin/nexus stop
nexus 配置文件 etc/nexus-default.properties
application-port=8081
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\nexus-pro-featurenexus.hazelcast.discovery.isEnabled=true
nexus jvm配置文件: bin/nexus.vmoptions
-Xms2703m
-Xmx2703m
-XX:MaxDirectMemorySize=2703m
-XX:+UnlockDiagnosticVMOptions
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Dkaraf.log=../sonatype-work/nexus3/log
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false
-Djdk.tls.ephemeralDHKeySize=2048
4.nexus 配置
nexus 启动以后,访问web管理页面 http://ip:8081
点击右上角登录,弹出登录框,显示admin默认密码路径:/usr/local/sonatype-work/nexus3/admin.password
登录成功,根据向导设置
修改密码以后,设置匿名访问:
启用匿名访问意味着默认情况下,用户可以在没有凭据的情况下从存储库搜索、浏览和下载组件。请考虑对您的组织的安全影响。
禁用匿名访问应该谨慎选择,因为它需要所有用户和/或构建工具的凭据。
允许仓库部署和更新:
5.maven上传jar到nexus
本地settings.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| The path to the local repository maven will use to store artifacts.|| Default: ${user.home}/.m2/repository<localRepository>/path/to/local/repo</localRepository>--><!--修改成本地的存储路径 --><localRepository>${user.home}/.m3/repository</localRepository><pluginGroups><!-- pluginGroup| Specifies a further group identifier to use for plugin lookup.<pluginGroup>com.your.plugins</pluginGroup>--></pluginGroups><!-- proxies| This is a list of proxies which can be used on this machine to connect to the network.| Unless otherwise specified (by system property or command-line switch), the first proxy| specification in this list marked as active will be used.|--><proxies></proxies><servers><!-- 配置发布到 Release 仓库的凭据 --><server><id>nexus-releases</id><username>admin</username><password>admin123</password></server><!-- 配置发布到 Snapshot 仓库的凭据(如果适用)--><server><id>nexus-snapshots</id><username>admin</username><password>admin123</password></server></servers><!-- 仓库地址列表 用于从远程存储库下载文件--><mirrors><mirror><id>nexus</id><mirrorOf>*</mirrorOf><name>nexus</name><url>http://10.10.1.185:8081/repository/maven-public/</url></mirror></mirrors><profiles><profile><id>nexus</id><!--Enable snapshots for the built in central repo to direct --><!--all requests to nexus via the mirror --><repositories><repository><id>central</id><!-- 根据实际情况填写 例如:http://10.10.1.185:8081/repository/maven-public/--><url>http://central</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>central</id><!-- 根据实际情况填写 例如:http://10.10.1.185:8081/repository/maven-public/--><url>http://central</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository></pluginRepositories></profile></profiles><!-- activeProfiles| List of profiles that are active for all builds.|--><activeProfiles><activeProfile>nexus</activeProfile></activeProfiles></settings>
idea maven配置:
File->Settings->Maven->
创建maven项目,pom.xml新增部署仓库配置:
<!-- 指定项目的部署仓库 --><distributionManagement><repository><id>nexus-releases</id><name>Nexus Release Repository</name><url>http://10.10.1.185:8081/repository/maven-releases/</url></repository><snapshotRepository><id>nexus-snapshots</id><name>Nexus Snapshot Repository</name><url>http://10.10.1.185:8081/repository/maven-snapshots/</url></snapshotRepository></distributionManagement>
注意:id的内容需要和settings.xml配置中的server id一致
上传jar包到nexus:
方式一:选中项目-》右键->run Maven->deploy
方式二:maven命令
mvn clean deploy
上传成功:
注意:如果版本号是以 SNAPSHOT结尾的如"1.0-SNAPSHOT",部署成功,jar被部署到maven-snapshots仓库。以其他则部署到maven-releases仓库。
新建maven项目,添加最近上传的依赖:
<dependency><groupId>cn.nexus.demo</groupId><artifactId>nexus-demo-biz2</artifactId><version>3.0.0</version></dependency>
执行打包命令:
mvn clean package
打包成功输出: