最近用dubbo做项目和第三方频繁RPC调用,如果对方改了接口参数或者新增接口,后台所有开发人员都需要把第三方提供的jar包打成pom文件引入本地环境。很累!!!

今天就给大家分享一下搭建Nexus3Maven私服以及上传并使用私服jar包

1、下载私服软件包:

1.1、官网下载:

地址:https://fr.sonatype.com/download-oss-sonatype

填写邮箱进行下载:

1.2、百度云盘下载(版本为:3.25):

下载链接: https://pan.baidu.com/s/1aOA8BVEmjDurgDfJ8EBpmQ 提取码: x65c

2、上传私服软件包到服务器:

3、解压私服软件包:

解压命令:
tar -zxvf nexus-3.25.1-04-unix.tar.gz

解压完之后(会有2个文件夹):

4、私服配置(可以忽略)

4.1、更改私服默认端口(8081):

//进入etc文件夹
cd  /DATA/nexus3/nexus-3.25.1-04/etc
//修改配置
vim nexus-default.properties
//更改端口号 port
application-port=12001

4.2、修改私服内存分配:

//进入bin目录
cd /DATA/nexus3/nexus-3.25.1-04/bin
//修改nexus.vmoptions
vim nexus.vmoptions

5、启动nexus3

(必须有jdk环境哈,如果没有安装jdk请移步:https://blog.cnbuilder.cn/archives/linuxinstalljdk)

启动命令 &为后台启动:
./nexus run & 也可以改为./nexus start &

启动成功:

6、访问Nexus3 ip+端口

7、登录

7.1、寻找admin的登录密码

进入他给你说的目录,然后寻找密码(文件里面就是admin密码):

7.2、拿到密码进行登录:

7.3、修改新的密码:

这就是登录成功的系统:

7.4、可以新建私服用户以及新建角色:

8、创建仓库:

目前创建4个仓库(本地-快照仓库、本地-正式仓库、代理仓库、以及综合仓库)

本地-快照仓库:就是为发布的jar包,比如测试jar

本地-正式仓库:就是第三方给我们提供的jar包,不需要在修改的jar包。

代理仓库:代理华为云、阿里云的或者mavne总仓库

综合仓库:把上面合成一个仓库,都可以使用。

8.1、创建本地快照仓库-也就是测试jar包存放的仓库。

8.1.1、选择maven本地仓库:

8.1.2、创建本地快照仓库:

8.1.3、创建成功:

8.2、创建本地Release仓库:

8.2.1、创建release版本仓库:

8.2.2、创建成功:

8.3、创建代理仓库(比如阿里云、华为云。。。)

8.3.1、创建代理仓库:

8.3.2、创建代理仓库:

8.3.3、创建成功:

8.4、创建组合仓库:

8.4.1、选择组合仓库的其他仓库地址

8.4.2、创建成功:

9、发布jar到私服:

9.1、先在本地解压一个新的mavne环境

9.2、修改setting文件:

9.2.1、修改本地仓库地址:

 <!--自定义maven本地仓库地址--><localRepository>D:\hcr\dev\apps\test_nexus3\apache-maven-3.6.3-bin\apache-maven-3.6.3\resp</localRepository>

9.2.2、新增servers的配置 指定发布版本账号密码

<servers><server>  <id>kingyifan-releases</id>  <username>admin</username>  <password>admin123</password>  </server><server>  <id>kingyifan-snapshots</id>  <username>admin</username>  <password>admin123</password>  </server>   </servers>

9.3、获取release仓库和快照仓库的地址:

9.4、代码pom文件新增:

  <!--打包上传maven私服--><distributionManagement><repository><!--id的名字可以任意取,但是在setting文件中的属性<server>的ID与这里一致--><id>kingyifan-releases</id><!--指向仓库类型为host(宿主仓库)的储存类型为Release的仓库--><url>http://192.168.189.129:12001/repository/kingyifan-hosted-release/</url></repository><snapshotRepository><id>kingyifan-snapshots</id><url>http://192.168.189.129:12001/repository/kingyifan-hosted-snapshot/</url></snapshotRepository></distributionManagement>

9.4,1、更改idea的maven仓库地址:

9.4.2、发布到私服。

命令:mvn deploy

或者用idea的打包工具:

自动就打到快照版本了。

Q: 为什么自动到快照版本而不是release版本呢?

A: 因为我们创建项目的时候指定的版本号就是快照版本。

9.5、如果只有jar包怎么上传私服呢??别急听我继续吹~

9.5.1、选择上传的仓库地址(只能选择发布版本)

9.5.2、上传jar包并且命名

9.5.3、上传成功:

9.5.4、查看

10、本地使用私服环境并且从私服下载jar包。

10.1、配置maven的setting配置文件:

10.1.1、增加综合仓库的服务器配置

<server><id>nexus-kingyifan</id><username>admin</username><password>admin123</password></server>

10.1.2、增加私服的综合仓库地址:

<mirrors><!-- mirror| Specifies a repository mirror site to use instead of a given repository. The repository that| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.|<mirror><id>mirrorId</id><mirrorOf>repositoryId</mirrorOf><name>Human Readable Name for this Mirror.</name><url>http://my.repository.com/repo/path</url></mirror>--><mirror><id>nexus-kingyifan</id><name>internal nexus repository</name><!--镜像采用配置好的组的地址--><url>http://192.168.189.129:12001/repository/kingyifan-group/</url><mirrorOf>!internal.repo,*</mirrorOf></mirror></mirrors>

10.1.3、配置仓库列表:

<profiles><profile><id>jdk-1.8</id><activation><activeByDefault>true</activeByDefault><jdk>1.8</jdk></activation><properties><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target><maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion></properties></profile><profile><id>nexus-kingyifan</id><!-- 远程仓库列表 --><repositories><repository><id>nexus-kingyifan</id><name>Nexus Central</name><!-- 虚拟的URL形式,指向镜像的URL--><url>http://192.168.189.129:12001/repository/kingyifan-group/</url><layout>default</layout><!-- 表示可以从这个仓库下载releases版本的构件--> <releases><enabled>true</enabled></releases><!-- 表示可以从这个仓库下载snapshot版本的构件 --> <snapshots><enabled>true</enabled></snapshots></repository></repositories><!-- 插件仓库列表 --><pluginRepositories><pluginRepository><id>nexus-kingyifan</id><name>Nexus Central</name><url>http://192.168.189.129:12001/repository/kingyifan-group/</url><layout>default</layout><snapshots><enabled>true</enabled></snapshots><releases><enabled>true</enabled></releases></pluginRepository></pluginRepositories></profile></profiles><activeProfiles><!--需要激活 <profile>中的ID才生效--> <activeProfile>nexus-kingyifan</activeProfile><activeProfile>jdk-1.8</activeProfile></activeProfiles>

来给大家甩一个完整的maven的setting配置文件:

<?xml version="1.0" encoding="UTF-8"?><!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
--><!--| This is the configuration file for Maven. It can be specified at two levels:||  1. User Level. This settings.xml file provides configuration for a single user,|                 and is normally provided in ${user.home}/.m2/settings.xml.||                 NOTE: This location can be overridden with the CLI option:||                 -s /path/to/user/settings.xml||  2. Global Level. This settings.xml file provides configuration for all Maven|                 users on a machine (assuming they're all using the same Maven|                 installation). It's normally provided in|                 ${maven.conf}/settings.xml.||                 NOTE: This location can be overridden with the CLI option:||                 -gs /path/to/global/settings.xml|| The sections in this sample file are intended to give you a running start at| getting the most out of your Maven installation. Where appropriate, the default| values (values used when the setting is not specified) are provided.||-->
<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>--><!--自定义maven本地仓库地址--><localRepository>D:\hcr\dev\apps\test_nexus3\apache-maven-3.6.3-bin\apache-maven-3.6.3\resp</localRepository><!-- interactiveMode| This will determine whether maven prompts you when it needs input. If set to false,| maven will use a sensible default value, perhaps based on some other setting, for| the parameter in question.|| Default: true<interactiveMode>true</interactiveMode>--><!-- offline| Determines whether maven should attempt to connect to the network when executing a build.| This will have an effect on artifact downloads, artifact deployment, and others.|| Default: false<offline>false</offline>--><!-- pluginGroups| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.|--><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><!-- proxy| Specification for one proxy, to be used in connecting to the network.|<proxy><id>optional</id><active>true</active><protocol>http</protocol><username>proxyuser</username><password>proxypass</password><host>proxy.host.net</host><port>80</port><nonProxyHosts>local.net|some.host.com</nonProxyHosts></proxy>--></proxies><!-- servers| This is a list of authentication profiles, keyed by the server-id used within the system.| Authentication profiles can be used whenever maven must make a connection to a remote server.|--><servers><server>  <id>kingyifan-releases</id>  <username>admin</username>  <password>admin123</password>  </server><server>  <id>kingyifan-snapshots</id>  <username>admin</username>  <password>admin123</password>  </server><server><id>nexus-kingyifan</id><username>admin</username><password>admin123</password></server> </servers><!-- mirrors| This is a list of mirrors to be used in downloading artifacts from remote repositories.|| It works like this: a POM may declare a repository to use in resolving certain artifacts.| However, this repository may have problems with heavy traffic at times, so people have mirrored| it to several places.|| That repository definition will have a unique id, so we can create a mirror reference for that| repository, to be used as an alternate download site. The mirror site will be the preferred| server for that repository.|--><mirrors><!-- mirror| Specifies a repository mirror site to use instead of a given repository. The repository that| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.|<mirror><id>mirrorId</id><mirrorOf>repositoryId</mirrorOf><name>Human Readable Name for this Mirror.</name><url>http://my.repository.com/repo/path</url></mirror>--><mirror><id>nexus-kingyifan</id><name>internal nexus repository</name><!--镜像采用配置好的组的地址--><url>http://192.168.189.129:12001/repository/kingyifan-group/</url><mirrorOf>!internal.repo,*</mirrorOf></mirror></mirrors><!-- profiles| This is a list of profiles which can be activated in a variety of ways, and which can modify| the build process. Profiles provided in the settings.xml are intended to provide local machine-| specific paths and repository locations which allow the build to work in the local environment.|| For example, if you have an integration testing plugin - like cactus - that needs to know where| your Tomcat instance is installed, you can provide a variable here such that the variable is| dereferenced during the build process to configure the cactus plugin.|| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles| section of this document (settings.xml) - will be discussed later. Another way essentially| relies on the detection of a system property, either matching a particular value for the property,| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.| Finally, the list of active profiles can be specified directly from the command line.|| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact|       repositories, plugin repositories, and free-form properties to be used as configuration|       variables for plugins in the POM.||--><profiles><profile><id>jdk-1.8</id><activation><activeByDefault>true</activeByDefault><jdk>1.8</jdk></activation><properties><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target><maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion></properties></profile><profile><id>nexus-kingyifan</id><!-- 远程仓库列表 --><repositories><repository><id>nexus-kingyifan</id><name>Nexus Central</name><!-- 虚拟的URL形式,指向镜像的URL--><url>http://192.168.189.129:12001/repository/kingyifan-group/</url><layout>default</layout><!-- 表示可以从这个仓库下载releases版本的构件--> <releases><enabled>true</enabled></releases><!-- 表示可以从这个仓库下载snapshot版本的构件 --> <snapshots><enabled>true</enabled></snapshots></repository></repositories><!-- 插件仓库列表 --><pluginRepositories><pluginRepository><id>nexus-kingyifan</id><name>Nexus Central</name><url>http://192.168.189.129:12001/repository/kingyifan-group/</url><layout>default</layout><snapshots><enabled>true</enabled></snapshots><releases><enabled>true</enabled></releases></pluginRepository></pluginRepositories></profile></profiles><activeProfiles><!--需要激活 <profile>中的ID才生效--> <activeProfile>nexus-kingyifan</activeProfile><activeProfile>jdk-1.8</activeProfile></activeProfiles><!-- activeProfiles| List of profiles that are active for all builds.|<activeProfiles><activeProfile>alwaysActiveProfile</activeProfile><activeProfile>anotherAlwaysActiveProfile</activeProfile></activeProfiles>-->
</settings>

10.1.4、敲黑板:IDEAmaven环境一定更换为刚刚修改的setting配置文件!!!

10.1.5、引入pom包:

自己就会去私服下载jar包

我们看一下本地maven仓库也是有对应的jar包的:

11、私服-下载jar包路径:

本地仓库===》私服发布版本===》私服正式版本===》私服代理仓库===》直到寻找结束。

终、、,以上centos7搭建私服,上传并使用私服jar包。


欢迎关注猿码优创

史上最全搭建MAVEN私服上传并使用JAR包教程相关推荐

  1. 史上最全的nexus私服搭建全流程

    序言 maven私服类似.net中的nuget包服务器 官网/版本收费 首先要吐槽官网慢的一比,下载不下来. 地址:https://www.sonatype.com/ 下载地址:https://www ...

  2. Maven入门:使用Nexus搭建Maven私服及上传下载jar包

    一. 私服搭建及配置 1 . 私服简介 私服是架设在局域网的一种特殊的远程仓库,目的是代理远程仓库及部署第三方构件.有了私服之后,当 Maven 需要下载构件时,直接请求私服,私服上存在则下载到本地仓 ...

  3. hexo史上最全搭建教程(转载)

    转载 hexo史上最全搭建教程 2018-09-16 20:19:08 zjufangzh 阅读数 46445 收起 分类专栏: 日常技术 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA ...

  4. 使用Nexus搭建Maven私服教程(附:nexus上传、下载教程)

    一.基本介绍(Nexus(maven私服)) 1,如果没有搭建私服会有什么问题? 如果没有私服,我们所需的所有构件都需要通过 Maven 的中央仓库或者第三方的 Maven 仓库下载到本地,而一个团队 ...

  5. 使用Nexus搭建Maven私服、私服下载与上传

    目录 一.概念 1.私服简介 2.私服的好处 3.搭建私服的开源仓库管理软件 二.使用Nexus搭建Maven私服(Windows环境) 1.安装jdk 2.下载即安装Nexus 2.1 下载 2.2 ...

  6. maven私服上传jar包

    maven私服上传jar包 登录maven私服 上传jar 登录maven私服 点击Repositories,选择上传到的仓库 3rd party 上传jar 选择Artifact Upload 选择 ...

  7. 搭建Maven私服那点事

    摘要:本文主要介绍在CentOS7.1下使用nexus3.6.0搭建maven私服,以及maven私服的使用(将自己的Maven项目指定到私服地址.将第三方项目jar上传到私服供其他项目组使用) 一. ...

  8. linux设置nexus开机自启动_在linux中使用nexus搭建maven私服

    首先介绍下为什么要搭建maven私服,简单点说就是就是把项目工程中的Jar包放在一个服务器上,每次Jar包的修改都能去私服上面Down到本地.可以对整个项目组的人形成一个统一的管理. 2.下载完之后就 ...

  9. Maven学习总结(九)——使用Nexus搭建Maven私服

    2019独角兽企业重金招聘Python工程师标准>>> Maven学习总结(九)--使用Nexus搭建Maven私服 一.搭建nexus私服的目的 为什么要搭建nexus私服,原因很 ...

最新文章

  1. 爱奇艺才被做空又爆裁员,技术研发为裁员重灾区
  2. html5 测试视频
  3. data后缀文件解码_WMA文件格式和解码流程 | 学步园
  4. 南工程计算机学院贴吧,【计算机工程学院答疑转帖】
  5. 【学习笔记】第五章 python3核心技术与实践--字典和集合
  6. Java 多线程 —— AQS 详解
  7. ORACLE 查询所有用户调度作业
  8. mysql hdfs_MySQL数据库与HDFS的实时数据同步
  9. uiswitchbutton 点击不改变状态_ES6专题—Generator与react状态机(14)
  10. mysql 5.1 双机热备_mysql5.1双机热备记录
  11. redis 条件查询
  12. php 查看常量值,[thinkphp]查看thinkphp系统定义的常量值
  13. CentOS 命令登录MySQL时,报错ERROR 1045 (28000) Access denied for user root
  14. Eclipse 安装教程附免费安装包资源
  15. 安装WINCC6.0的步骤
  16. 点击 按钮 下载图片
  17. SDU CS 期末考回忆版合集
  18. eclipse的简介
  19. ridge regression and lasso analysis-reproduced from csdn
  20. 新注册Apple ID无法登陆 Apple Store,出现安全性提示

热门文章

  1. STUFF()函数将查询的多行数据合并为一行
  2. c# 发送邮件保存服务器,c#-使用SmtpClient时如何保存电子邮件而不是发送电子邮件?...
  3. C# 获取简体繁体汉字首字母-汉字转拼音
  4. 在windows7中删除onekey还原启动项方法
  5. 毕业5年,我问遍了身边的大佬,总结了他们的学习方法
  6. 银联电子支付 php chinapay
  7. 数据库 explain详解
  8. 阿里2017校园招聘电话面试总结
  9. R语言ggplot2可视化:使用patchwork包将两个ggplot2可视化结果组合起来、使用labs函数为第二个子图添加标题信息
  10. X265码率控制——ABR算法基本原理 源码解读