Java充电社
专辑
博文
联系我
本人继续续收门徒,亲手指导
Maven教程
-> 私服详解
1、maven入门
2、安装、配置、mvn运行过程详解
3、坐标和依赖详解
4、仓库详解
5、私服详解
6、生命周期和插件详解
7、聚合、继承、裁剪详解
8、多模块任意构建,必备神技能
9、多环境构建支持
10、自定义插件,Maven的生命交给你来设计
上一篇:仓库详解
下一篇:生命周期和插件详解
<div style="display:none"></div> **maven系列目标:从入门开始开始掌握一个高级开发所需要的maven技能。** 这是maven系列第5篇。 **整个maven系列的内容前后是有依赖的,如果之前没有接触过maven,建议从第一篇看起,本文尾部有maven完整系列的连接。** ## 环境 1. maven3.6.1 2. 开发工具idea 3. jdk1.8 ## 本篇内容 1. 私服介绍 2. windows中安装nexus私服 3. linux中安装nexus私服 4. nexus私服中各种仓库详解 5. 配置本地Maven从nexus下载构件 6. 将本地构件发布到私服的2种方式详解 7. 总结 上一篇文章中有提到了私服,我们再来回顾一下私服相关的内容。 ## 私服 私服也是远程仓库中的一种,我们为什么需要私服呢? 如果我们一个团队中有几百个人在开发一些项目,都是采用maven的方式来组织项目,那么我们每个人都需要从远程仓库中把需要依赖的构件下载到本地仓库,这对公司的网络要求也比较高,为了节省这个宽带和加快下载速度,我们在公司内部局域网内部可以架设一台服务器,这台服务器起到一个代理的作用,公司里面的所有开发者去访问这个服务器,这台服务器将需要的构件返回给我们,如果这台服务器中也没有我们需要的构件,那么这个代理服务器会去远程仓库中查找,然后将其先下载到代理服务器中,然后再返回给开发者本地的仓库。 还有公司内部有很多项目之间会相互依赖,你可能是架构组的,你需要开发一些jar包给其他组使用,此时,我们可以将自己jar发布到私服中给其他同事使用,如果没有私服,可能需要我们手动发给别人或者上传到共享机器中,不过管理起来不是很方便。 **总体上来说私服有以下好处:** 1. 加速maven构件的下载速度 2. 节省宽带,加速项目构建速度 3. 方便部署自己的构件以供他人使用 4. 提高maven的稳定性,中央仓库需要本机能够访问外网,而如果采用私服的方式,只需要本机可以访问内网私服就可以了 有3种专门的maven仓库管理软件可以用来帮助我们搭建私服: 1. Apache基金会的archiva ```java http://archiva.apache.org/ ``` 2. JFrog的Artifactory ```java https://jfrog.com/artifactory/ ``` 3. Sonatype的Nexus ```java https://my.sonatype.com/ ``` 这些都是开源的私服软件,都可以自由使用。用的最多的是第三种Nexus,本文我们主要以这个来讲解,其他2种有兴趣的朋友可以去研究一下。 nexus是java开发的,所以运行的时候需要有java环境的支持。 ## Windows10中安装Nexus私服 ### 安装jdk 安装jdk1.8,可以参考<a href="/course/2/63" target="_blank">Maven系列第2篇:安装、配置、mvn运行过程详解</a>这篇文章中有介绍 ### 下载nexus > 下面提供两种下载方式:官网下载、百度网盘下载,百度网盘速度会快一些。 > > 官网和百度网盘中都包含了windows、linux、mac版本nexus安装文件。 > > 建议大家使用网盘中的资源,保持和本文环境一致,可以避免出错。 #### nexus下载地址 ```java https://help.sonatype.com/repomanager3/download ``` ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/003e7003-3bc8-4ae7-8029-e2560b0e65eb.png) #### 百度网盘下载地址 ```java 链接:https://pan.baidu.com/s/1N8A4JH1Ykvetn3xs05LszA 提取码:vig6 复制这段内容后打开百度网盘手机App,操作更方便哦 ``` ### 解压latest-win64.zip > latest-win64.zip解压之后会产生两个文件目录nexus-3.19.1-01和sonatyp-work ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/c7c72829-5f97-4164-9a33-e69330843370.png) ### 启动nexus cmd中直接运行`nexus-3.19.1-01/bin/nexus.exe /run` ,如下: ```shell D:\installsoft\maven\nexus\nexus-3.19.1-01\bin>nexus.exe /run ``` 如果输出中出现了下面的异常请忽略 ``` java.io.UnsupportedEncodingException: Encoding GBK is not supported yet (feel free to submit a patch) ``` 浏览器中打开 ```java http://localhost:8081/ ``` 效果如下: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/a953ffd8-2077-415b-a1c6-d546782a224d.png) ### 登录Nexus 点击上图右上角的`Sign in`,输入用户名和密码,nexus默认用户名是`admin` nexus这个版本的密码是第一次启动的时候生成的,密码位于下面的文件中: ```java 安装目录/sonatype-work/nexus3/admin.password ``` 登录成功后会弹出一些设置,如下: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/04876d7e-a999-45a1-9f96-fce646517e48.png) 点击`Next`,设置新的登录密码(新密码要保存好),如下: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/548e6df5-73e8-4fd3-87c0-a4a1ba258234.png) 点击`Next`->`Finish`完成设置。 ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/6822f69b-4e10-4575-aa7f-f7d21c110b0d.png) ### 其他一些常见的操作 #### 停止Nexus的命令 启动的cmd窗口中按:`ctrl+c`,可以停止Nexus。 #### 修改启动端口 默认端口是8081,如果和本机有冲突,可以在下面的文件中修改: ```java nexus-3.19.1-01\etc\nexus-default.properties ``` > nexus使用java开发的web项目,内置了jetty web容器,所以可以直接运行。 ## Linux安装Nexus私服 ### 下载安装包 百度网盘中下载linux版本的nexus安装包,选择`latest-unix.tar.gz`文件,下载地址如下: ```java 链接:https://pan.baidu.com/s/1N8A4JH1Ykvetn3xs05LszA 提取码:vig6 复制这段内容后打开百度网盘手机App,操作更方便哦 ``` 将上面的安装包放在`/opt/nexus/`目录。 ### 解压 ```powershell [root@test1117 nexus]# tar -zvxf latest-unix.tar.gz [root@test1117 nexus]# ls latest-unix.tar.gz nexus-3.19.1-01 sonatype-work ``` ### 启动 ```shell [root@test1117 bin]# /opt/nexus/nexus-3.19.1-01/bin/nexus start WARNING: ************************************************************ WARNING: Detected execution as "root" user. This is NOT recommended! WARNING: ************************************************************ Starting nexus ``` > 我上面使用的是root用户操作的,为了安全性,你们最好自己创建个用户来操作。 ### 开放端口 在`/etc/sysconfig/iptables`文件中加入下面内容: ```shell -A INPUT -p tcp -m state --state NEW -m tcp --dport 8081 -j ACCEPT ``` 执行下面命令,让上面配置生效: ``` [root@test1117 bin]# service iptables restart Redirecting to /bin/systemctl restart iptables.service ``` ### 验证效果 访问 ```java http://nexus私服所在的机器ip:8081/ ``` 出现下面效果表示一切ok。 ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/2eb3845c-9cec-4e1e-b088-e9ea2b74a160.png) ### 登录 用户名为`admin`,密码在 ``` /opt/nexus/sonatype-work/nexus3/admin.password ``` 登录之后请请立即修改密码。 ## Nexus中仓库分类 前面我们说过,用户可以通过nexus去访问远程仓库,可以将本地的构件发布到nexus中,nexus是如何支撑这些操作的呢? nexus中有个仓库列表,里面包含了各种各样的仓库,有我们说的被代理的第三方远程仓库,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/c5ec094d-85aa-4019-8e1b-5f04ce65b61b.png) 上图中是nexus安装好默认自带的仓库列表,主要有3种类型: 1. 代理仓库 2. 宿主仓库 3. 仓库组 ### 代理仓库 代理仓库主要是让使用者通过代理仓库来间接访问外部的第三方远程仓库的,如通过代理仓库访问maven中央仓库、阿里的maven仓库等等。代理仓库会从被代理的仓库中下载构件,缓存在代理仓库中以供maven用户使用。 我们在nexus中创建一个阿里云的maven代理仓库来看下过程如下。 Nexus仓库列表中点击`Create repository`按钮,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/dcda6824-54b1-44a0-906e-e22dccfae45a.png) 进入添加页面,选择`maven2(proxy)`,这个表示`代理仓库`,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/c4347463-3c94-4484-b03a-779b3e75dd4f.png) 输入远程仓库的信息,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/3ac65348-ff20-4395-b919-346140c6cb1d.png) ```java 第一个红框中输入仓库名称:maven-aliyun 第二个红框选择:Release,表示从这个仓库中下载稳定版的构件 第三个红框输入阿里云仓库地址:https://maven.aliyun.com/repository/public ``` 点击底部的`Create repository`按钮,创建完成,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/edb2ddac-f53a-4898-8c29-c17d66630c63.png) ### 宿主仓库 宿主仓库主要是给我们自己用的,主要有2点作用 1. 将私有的一些构件通过nexus中网页的方式上传到宿主仓库中给其他同事使用 2. 将自己开发好一些构件发布到nexus的宿主仓库中以供其他同事使用 上面这2种操作,一会稍后会详解以及演示操作过程。 ### 仓库组 maven用户可以从代理仓库和宿主仓库中下载构件至本地仓库,为了方便从多个代理仓库和宿主仓库下载构件,maven提供了仓库组,仓库组中可以有多个代理仓库和宿主仓库,而maven用户只用访问一个仓库组就可以间接的访问这个组内所有的仓库,仓库组中多个仓库是有顺序的,当maven用户从仓库组下载构件时,仓库组会按顺序依次在组内的仓库中查找组件,查找到了立即返回给本地仓库,所以一般情况我们会将速度快的放在前面。 仓库组内部实际上是没有构件内容的,他只是起到一个请求转发的作用,将maven用户下载构件的请求转发给组内的其他仓库处理。 nexus默认有个仓库组`maven-public`,如下: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/26a6ea9a-95db-4950-a628-2d91595511eb.png) 点击一下`maven-public`这行记录,进去看一下,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/8edc2a72-f96c-4d75-b8d2-3dc8ffee6ca8.png) > 上图中第一个红框是这个仓库组对外的一个url,我们本地的maven可以通过这个url来从仓库组中下载构件至本地仓库。 > > 第二个红框中是这个仓库组中的成员,目前包含了3个仓库,第1个是宿主的releases版本仓库,第1个是宿主快照版本的仓库,第3个是代理仓库(maven社区中央仓库的代理)。 > > 刚才我们新增的`maven-aliyun`在左边,我们将其也加到右边的仓库成员(`Members`)列表,然后将`maven-aliyun`这个仓库放在第3个位置,这个仓库的速度比`maven-central`要快一些,能加速我们下载maven构件的速度,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/1ebb429b-2aab-49c5-b19d-3a75ef0359a1.png) ## 配置本地Maven从nexus下载构件 介绍2种方式 ### 方式1:pom.xml的方式 本次我们就从nexus默认仓库组中下载构件,先获取仓库组对外的地址,点击下图中的`copy`按钮,获取仓库组的地址: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/fc52b473-da00-4386-92f6-b0edf84b67dd.png) ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/594ce3b9-995e-4519-be48-b0ced56b68c4.png) 修改pom.xml,加入如下内容: > 注意下面`url`的地址为上面复制的地址。 ```java <repositories> <repository> <id>maven-nexus</id> <url>http://localhost:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> ``` 由于nexus私服需要有用户名和密码登录才能访问,所以需要有凭证,凭证需要在settings.xml文件中配置,在`~/.m2/settings.xml`文件的`servers`元素中加入如下内容: ```xml <server> <id>maven-nexus</id> <username>admin</username> <password>admin123</password> </server> ``` > 注意上面的`server->id`的值和`pom.xml中repository->id`的值一致,通过这个id关联找到凭证的。 > > server元素中的username和password你们根据自己的去编辑,我这边密码设置的是admin123 ### 方式1示例 创建一个maven项目,打开idea,点击`File->New->Project`,选择`Maven`,如下: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/0caaf1e0-f309-40d1-8803-5e4e6c65586e.png) 点击`Next`,输入项目坐标信息,如下: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/a7fae043-83f6-4666-aa54-44d1d6a56bfe.png) 点击`Next`,输入Project name 为`maven-chat05`,如下: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/6b083469-de49-4e16-919c-6fa8d340540d.png) 点击`Finish`,创建成功,如下: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/e88b8882-d656-41bb-85c4-6ec2b2ab75d5.png) 配置一下idea的maven环境,点击`File->Settings`,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/7c550230-7d7a-440c-95d2-0bfd98bd727a.png) 点击上面的`OK`完成配置。 还原`~/.m2/settings.xml`的配置到初始状态,操作如下: ```java 将M2_HOME/conf/settings.xml复制熬~/.m2/settings.xml目录,如果存在先备份一个,然后进行覆盖。 ``` 修改上面idea项目中的pom.xml文件,内容如下: ```xml <?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>com.javacode2018</groupId> <artifactId>maven-chat05</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.62</version> </dependency> </dependencies> <repositories> <repository> <id>maven-nexus</id> <url>http://localhost:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </project> ``` 删除本地仓库中以下几个目录: ```java ~\.m2\repository\com\alibaba ``` maven-chat05项目目录中打开cmd运行: ```java mvn compile ``` 见证奇迹的时刻,输出如下: ```java D:\code\IdeaProjects\maven-chat05>mvn compile [INFO] Scanning for projects... [INFO] [INFO] -------------------< com.javacode2018:maven-chat05 >-------------------- [INFO] Building maven-chat05 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- Downloading from maven-nexus: http://localhost:8081/repository/maven-public/com/alibaba/fastjson/1.2.62/fastjson-1.2.62.pom Downloaded from maven-nexus: http://localhost:8081/repository/maven-public/com/alibaba/fastjson/1.2.62/fastjson-1.2.62.pom (9.7 kB at 5.1 kB/s) Downloading from maven-nexus: http://localhost:8081/repository/maven-public/com/alibaba/fastjson/1.2.62/fastjson-1.2.62.jar Downloaded from maven-nexus: http://localhost:8081/repository/maven-public/com/alibaba/fastjson/1.2.62/fastjson-1.2.62.jar (658 kB at 70 kB/s) [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-chat05 --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-chat05 --- [INFO] Nothing to compile - all classes are up to date [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 16.083 s [INFO] Finished at: 2019-11-13T15:45:44+08:00 [INFO] ------------------------------------------------------------------------ ``` 从输出中可以看出fastjson这个jar包从`maven-nexus`中下载了,下载地址正是我们nexus私服中的那个地址。 ### 方式2:镜像方式 关于什么是镜像,这里就不在做说明了,上篇文章中有介绍,可以移步过去看一下:[仓库详解](/course/2/65) 镜像的方式主要修改`~/.m2/setting.xml`文件,需要修改2处理。 #### 第1处:setting.xml的mirrors元素中加入如下配置: ```xml <mirror> <id>mirror-nexus</id> <mirrorOf>*</mirrorOf> <name>nexus镜像</name> <url>http://localhost:8081/repository/maven-public/</url> </mirror> ``` > 上面`mirrorOf`配置的`*`,说明所有远程仓库都通过该镜像下载构件。 > > url:这个为nexus中仓库组的地址,上面方式一中有说过。 #### 第2处:配置用户名密码 由于nexus的url是需要用户名和密码才可以访问的,所以需要配置访问凭证,在`~/.m2/settings.xml`文件的`servers`元素中加入如下内容: ```xml <server> <id>mirror-nexus</id> <username>admin</username> <password>admin123</password> </server> ``` > 注意上面的`server->id`的值和`mirror->id`的值需要一致,这样才能找到对应的凭证。 ### 方式2示例 还是以方式1中的maven项目maven-chat05为例。 修改pom.xml,内容如下: ```xml <?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>com.javacode2018</groupId> <artifactId>maven-chat05</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.62</version> </dependency> </dependencies> </project> ``` `~/.m2/settings.xml`的`servers`元素中加入下面内容: ```xml <server> <id>mirror-nexus</id> <username>admin</username> <password>admin123</password> </server> ``` > 注意上面username、password根据你们自己的进行配置。 `~/.m2/settings.xml`的`mirrors`元素中加入下面内容: ```xml <mirror> <id>mirror-nexus</id> <mirrorOf>*</mirrorOf> <name>nexus镜像</name> <url>http://localhost:8081/repository/maven-public/</url> </mirror> ``` 删除本地仓库中以下几个目录: ```java ~\.m2\repository\com\alibaba ``` maven-chat05项目目录中打开cmd运行: ```java mvn compile ``` 见证奇迹的时刻,输出如下: ```java D:\code\IdeaProjects\maven-chat05>mvn compile [INFO] Scanning for projects... [INFO] [INFO] -------------------< com.javacode2018:maven-chat05 >-------------------- [INFO] Building maven-chat05 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- Downloading from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom Downloaded from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom (0 B at 0 B/s) Downloading from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/maven/plugins/maven-plugins/23/maven-plugins-23.pom Downloaded from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/maven/plugins/maven-plugins/23/maven-plugins-23.pom (0 B at 0 B/s) Downloading from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/maven/maven-parent/22/maven-parent-22.pom Downloaded from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/maven/maven-parent/22/maven-parent-22.pom (0 B at 0 B/s) Downloading from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/apache/11/apache-11.pom Downloaded from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/apache/11/apache-11.pom (0 B at 0 B/s) Downloading from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.jar Downloaded from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.jar (0 B at 0 B/s) Downloading from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.pom Downloaded from mirror-nexus: http://localhost:8081/repository/maven-public/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.pom (0 B at 0 B/s) [INFO] Nothing to compile - all classes are up to date [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:23 min [INFO] Finished at: 2019-11-13T16:05:43+08:00 [INFO] ------------------------------------------------------------------------ ``` 输出内容比较多,只截取了部分输出,从输出中可以看出fastjson这个jar包从`mirror-nexus`中下载了,下载地址正是我们nexus私服中的那个地址,镜像的方式起效了,是不是感觉很爽,哈哈! ## 本地构件发布到私服 ### 经常用到的有2种 1. **使用maven部署构件至nexus私服** 2. **手动部署第三方构件至nexus私服**:比如我们第三方发给我们的一个包,比如短信发送商的jar包,这个包远程仓库是不存在的,我们要把这个包上传到私服供所有开发使用。 下面我们来看一下这两种如何操作。 ### 使用maven部署构件至nexus私服 我们创建maven项目的时候,会有一个pom.xml文件,里面有个version元素,这个是这个构件的版本号,可以去看一下上面我们刚创建的`maven-chat05`,默认是`1.0-SNAPSHOT`,这个以`-SNAPSHOT`结尾的表示是个快照版本,叫做`SNAPSHOT`版本,快照版本一般是不稳定的,会反复发布、测试、修改、发布。而最终会有一个稳定的可以发布的版本,是没有`-SNAPSHOT`后缀的,这个叫做`release`版本。 而nexus私服中存储用户的构件是使用的宿主仓库,这个我们上面也有说过,nexus私服中提供了两个默认的宿主仓库分别用来存放`SNAPSHOT`版本和`release`版本,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/76e13ebf-314f-4c3c-b166-a5b51070fa26.png) 上图中第1个红框的`maven-releases`宿主仓库用来存放用户自己release版本的构件。 第2个红框的`maven-snapshots`宿主仓库用来存放用户snapshot版本的构件。 上面两个仓库的地址可以点击后面的`copy`按钮获取。 #### 操作分为3步 #### 第一步:修改pom.xml配置 我们需要将本地maven项目的构件发布到上面宿主仓库中,需要修改项目中pom.xml的配置,加入下面内容: ```xml <distributionManagement> <repository> <id>release-nexus</id> <url>http://localhost:8081/repository/maven-releases/</url> <name>nexus私服中宿主仓库->存放/下载稳定版本的构件</name> </repository> <snapshotRepository> <id>snapshot-nexus</id> <url>http://localhost:8081/repository/maven-snapshots/</url> <name>nexus私服中宿主仓库->存放/下载快照版本的构件</name> </snapshotRepository> </distributionManagement> ``` > 上面2个url分别是上图中两个宿主仓库的地址。 #### 第二步:修改settings.xml 上面地址需要登录才可以访问,所以需要配置凭证,这个需要在`~/.m2/settings.xml`中进行配置,在这个文件的`servers`元素中加入: ```xml <server> <id>release-nexus</id> <username>admin</username> <password>admin123</password> </server> <server> <id>snapshot-nexus</id> <username>admin</username> <password>admin123</password> </server> ``` > 注意上面第1个`server->id`的值需要和pom.xml中的`distributionManagement->repository->id`的值一致。 > > 第2个`server->id`的值需要和pom.xml中的`distributionManagement->snapshotRepository->id`的值一致。 #### 第三步:执行 mvn deploy 命令 执行这个命令的时候,会对构件进行打包,然后上传到私服中。 这命令的原理,后面的文章中会具体介绍。 #### 示例效果 我们来感受一下效果。 按照上面的配置修改`maven-chat03/pom.xml`文件和本地的`~/.m2/settings.xml`文件。 maven-chat05项目目录中打开cmd运行: ```java mvn deploy ``` 见证奇迹的时刻,输出如下: ```java D:\code\IdeaProjects\maven-chat05>mvn deploy [INFO] Scanning for projects... [INFO] [INFO] -------------------< com.javacode2018:maven-chat05 >-------------------- [INFO] Building maven-chat05 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-chat05 --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-chat05 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-chat05 --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\code\IdeaProjects\maven-chat05\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-chat05 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-chat05 --- [INFO] No tests to run. [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-chat05 --- [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ maven-chat05 --- [INFO] Installing D:\code\IdeaProjects\maven-chat05\target\maven-chat05-1.0-SNAPSHOT.jar to C:\Users\Think\.m2\repository\com\javacode2018\maven-chat05\1.0-SNAPSHOT\maven-chat05-1.0-SNAPSHOT.jar [INFO] Installing D:\code\IdeaProjects\maven-chat05\pom.xml to C:\Users\Think\.m2\repository\com\javacode2018\maven-chat05\1.0-SNAPSHOT\maven-chat05-1.0-SNAPSHOT.pom [INFO] [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ maven-chat05 --- Downloading from snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-metadata.xml Uploading to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-chat05-1.0-20191113.083820-1.jar Uploaded to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-chat05-1.0-20191113.083820-1.jar (1.8 kB at 11 kB/s) Uploading to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-chat05-1.0-20191113.083820-1.pom Uploaded to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-chat05-1.0-20191113.083820-1.pom (1.2 kB at 10 kB/s) Downloading from snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/maven-metadata.xml Uploading to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-metadata.xml Uploaded to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-metadata.xml (772 B at 9.2 kB/s) Uploading to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/maven-metadata.xml Uploaded to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/maven-metadata.xml (286 B at 3.4 kB/s) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 6.156 s [INFO] Finished at: 2019-11-13T16:38:20+08:00 [INFO] ------------------------------------------------------------------------ ``` 输出内容中有`Uploading to snapshot-nexus、Uploaded to snapshot-nexus` ,`snapshot-nexus`正是我们在pom.xml配置的快照版本的地址,上面输出内容中有具体的地址,和快照的地址也是一样的,上传成功了。 我们去nexus私服中看一下,访问nexus私服中快照版本仓库的地址: ```java http://localhost:8081/repository/maven-snapshots/ ``` 出现如下页面: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/e52415a2-84f7-4dd1-8044-aa2ff35928dd.png) 点击上面的`bowse`连接,如下图,我们的构件上传成功了: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/83cd5809-accb-45ec-b798-6a72b3404393.png) 如果其他同事需要使用上面这个构件,只需要点击下图中的pom文件,右边会显示构件的坐标,然后可以拿去使用了,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/dae4173c-92ac-47cb-9d3b-eecc69bf4d47.png) 上面是将快照版本的发布到了nexus私服的快照宿主仓库了,下面我们再来操作一下将release稳定版本的发布到nexus私服,如下: 修改pom.xml文件的版本号,将`-SNAPSHOT`后缀去掉,去掉之后表示是release版本的了,如下: ```xml <version>1.0</version> ``` cmd命令中执行: ```java mvn deploy ``` 输出: ```java D:\code\IdeaProjects\maven-chat05>mvn deploy [INFO] Scanning for projects... [INFO] [INFO] -------------------< com.javacode2018:maven-chat05 >-------------------- [INFO] Building maven-chat05 1.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-chat05 --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-chat05 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-chat05 --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\code\IdeaProjects\maven-chat05\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-chat05 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-chat05 --- [INFO] No tests to run. [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-chat05 --- [INFO] Building jar: D:\code\IdeaProjects\maven-chat05\target\maven-chat05-1.0.jar [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ maven-chat05 --- [INFO] Installing D:\code\IdeaProjects\maven-chat05\target\maven-chat05-1.0.jar to C:\Users\Think\.m2\repository\com\javacode2018\maven-chat05\1.0\maven-chat05-1.0.jar [INFO] Installing D:\code\IdeaProjects\maven-chat05\pom.xml to C:\Users\Think\.m2\repository\com\javacode2018\maven-chat05\1.0\maven-chat05-1.0.pom [INFO] [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ maven-chat05 --- Uploading to release-nexus: http://localhost:8081/repository/maven-releases/com/javacode2018/maven-chat05/1.0/maven-chat05-1.0.jar Uploaded to release-nexus: http://localhost:8081/repository/maven-releases/com/javacode2018/maven-chat05/1.0/maven-chat05-1.0.jar (1.7 kB at 9.6 kB/s) Uploading to release-nexus: http://localhost:8081/repository/maven-releases/com/javacode2018/maven-chat05/1.0/maven-chat05-1.0.pom Uploaded to release-nexus: http://localhost:8081/repository/maven-releases/com/javacode2018/maven-chat05/1.0/maven-chat05-1.0.pom (1.2 kB at 12 kB/s) Downloading from release-nexus: http://localhost:8081/repository/maven-releases/com/javacode2018/maven-chat05/maven-metadata.xml Uploading to release-nexus: http://localhost:8081/repository/maven-releases/com/javacode2018/maven-chat05/maven-metadata.xml Uploaded to release-nexus: http://localhost:8081/repository/maven-releases/com/javacode2018/maven-chat05/maven-metadata.xml (304 B at 4.3 kB/s) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.646 s [INFO] Finished at: 2019-11-13T16:48:44+08:00 [INFO] ------------------------------------------------------------------------ ``` 输出中有`release-nexus`,说明使用了`pom.xml`中的`distributionManagement->repository->id`的值,上传地址是`http://localhost:8081/repository/maven-releases`。 打开nexus私服中release地址: ```java http://localhost:8081/repository/maven-releases/ ``` ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/0e254abc-ac15-4c4d-b41b-7a3b2b670b47.png) 点击上面的`browse`连接,如下: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/16b8d03f-64b8-4e76-946d-e40f72e7dc67.png) 成功了,是不是感觉很爽。 #### 使用注意 snapshot属于快照版本,同一个snapshot版本的构件可以重复部署到私服中,如果私服中已经存在了则会进行覆盖掉。 而release是稳定版本的构件,重复部署会报错,我们来演示一下,如下: 修改将pom.xml中的version修改为快照版本的,如下: ```xml <version>1.0-SNAPSHOT</version> ``` 再次部署,如下: ```java D:\code\IdeaProjects\maven-chat05>mvn deploy [INFO] Scanning for projects... [INFO] [INFO] -------------------< com.javacode2018:maven-chat05 >-------------------- [INFO] Building maven-chat05 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-chat05 --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-chat05 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-chat05 --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\code\IdeaProjects\maven-chat05\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-chat05 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-chat05 --- [INFO] No tests to run. [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-chat05 --- [INFO] Building jar: D:\code\IdeaProjects\maven-chat05\target\maven-chat05-1.0-SNAPSHOT.jar [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ maven-chat05 --- [INFO] Installing D:\code\IdeaProjects\maven-chat05\target\maven-chat05-1.0-SNAPSHOT.jar to C:\Users\Think\.m2\repository\com\javacode2018\maven-chat05\1.0-SNAPSHOT\maven-chat05-1.0-SNAPSHOT.jar [INFO] Installing D:\code\IdeaProjects\maven-chat05\pom.xml to C:\Users\Think\.m2\repository\com\javacode2018\maven-chat05\1.0-SNAPSHOT\maven-chat05-1.0-SNAPSHOT.pom [INFO] [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ maven-chat05 --- Downloading from snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-metadata.xml Downloaded from snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-metadata.xml (772 B at 5.9 kB/s) Uploading to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-chat05-1.0-20191114.065058-2.jar Uploaded to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-chat05-1.0-20191114.065058-2.jar (1.8 kB at 19 kB/s) Uploading to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-chat05-1.0-20191114.065058-2.pom Uploaded to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-chat05-1.0-20191114.065058-2.pom (1.2 kB at 14 kB/s) Downloading from snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/maven-metadata.xml Downloaded from snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/maven-metadata.xml (324 B at 9.0 kB/s) Uploading to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-metadata.xml Uploaded to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/1.0-SNAPSHOT/maven-metadata.xml (772 B at 8.7 kB/s) Uploading to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/maven-metadata.xml Uploaded to snapshot-nexus: http://localhost:8081/repository/maven-snapshots/com/javacode2018/maven-chat05/maven-metadata.xml (324 B at 3.3 kB/s) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.363 s [INFO] Finished at: 2019-11-14T14:50:59+08:00 [INFO] ------------------------------------------------------------------------ ``` 成功了。 我们再来看看release版本的,修改pom.xml中的version: ```xml <version>1.0</version> ``` 再次部署,如下: ```java D:\code\IdeaProjects\maven-chat05>mvn deploy [INFO] Scanning for projects... [INFO] [INFO] -------------------< com.javacode2018:maven-chat05 >-------------------- [INFO] Building maven-chat05 1.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-chat05 --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-chat05 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-chat05 --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\code\IdeaProjects\maven-chat05\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-chat05 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-chat05 --- [INFO] No tests to run. [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-chat05 --- [INFO] Building jar: D:\code\IdeaProjects\maven-chat05\target\maven-chat05-1.0.jar [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ maven-chat05 --- [INFO] Installing D:\code\IdeaProjects\maven-chat05\target\maven-chat05-1.0.jar to C:\Users\Think\.m2\repository\com\javacode2018\maven-chat05\1.0\maven-chat05-1.0.jar [INFO] Installing D:\code\IdeaProjects\maven-chat05\pom.xml to C:\Users\Think\.m2\repository\com\javacode2018\maven-chat05\1.0\maven-chat05-1.0.pom [INFO] [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ maven-chat05 --- Uploading to release-nexus: http://localhost:8081/repository/maven-releases/com/javacode2018/maven-chat05/1.0/maven-chat05-1.0.jar Uploading to release-nexus: http://localhost:8081/repository/maven-releases/com/javacode2018/maven-chat05/1.0/maven-chat05-1.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.967 s [INFO] Finished at: 2019-11-14T14:54:12+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project maven-chat05: Failed to deploy artifacts: Could not transfer artifact com.javacode2018:maven-chat05:jar:1.0 from/to release-nexus (http://localhost:8081/repository/maven-releases/): Failed to transfer file http://localhost:8081/repository/maven-releases/com/javacode2018/maven-chat05/1.0/maven-chat05-1.0.jar with status code 400 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException ``` 输出中有`400`的`ERROR`日志,部署失败。 ### 手动部署构件至nexus私服 #### 操作步骤 **手动上传只支持发布稳定版本的构件**,操作过程如下图: 登录nexus,按照下图的步骤依次点击: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/ab7d48ad-8c14-4049-aba4-4408306cc125.png) 图中第一行`maven-releases`宿主仓库就是存放用户自己构件的仓库,点击上图中列表中的第一行,进入上传页面,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/e830b0af-a436-4cac-9b99-bc81d3ec7d18.png) 上面页面中点击`Browse`选择本地的构件,然后输入其他坐标信息,点击`Upload`完成上传操作。 #### 示例效果 我们把`maven-chat05\target\maven-chat05-1.0.jar`上传上去,如下: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/881f668b-123b-4d10-871b-58913115bc05.png) 点击`Upload`完成上传操作。 访问如下地址: ```java http://localhost:8081/#browse/browse:maven-releases ``` 可以看到上传好的构件,如下图: ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/66/bd8883c2-533a-475b-86cf-4daf876190fa.png) ## 总结 **本文90%是实操部分,强烈建议大家去操作一遍,加深理解。如果有收获的帮忙分享一下,你们的支持也是我不断输出的一个动力,希望大家都能够学到东西!** <a style="display:none" target="_blank" href="https://mp.weixin.qq.com/s/_S1DD2JADnXvpexxaBwLLg" style="color:red; font-size:20px; font-weight:bold">继续收门徒,亲手带,月薪 4W 以下的可以来找我</a> ## 最新资料 1. <a href="https://mp.weixin.qq.com/s?__biz=MzkzOTI3Nzc0Mg==&mid=2247484964&idx=2&sn=c81bce2f26015ee0f9632ddc6c67df03&scene=21#wechat_redirect" target="_blank">尚硅谷 Java 学科全套教程(总 207.77GB)</a> 2. <a href="https://mp.weixin.qq.com/s?__biz=MzkwOTAyMTY2NA==&mid=2247484192&idx=1&sn=505f2faaa4cc911f553850667749bcbb&scene=21#wechat_redirect" target="_blank">2021 最新版 Java 微服务学习线路图 + 视频</a> 3. <a href="https://mp.weixin.qq.com/s?__biz=MzkwOTAyMTY2NA==&mid=2247484573&idx=1&sn=7f3d83892186c16c57bc0b99f03f1ffd&scene=21#wechat_redirect" target="_blank">阿里技术大佬整理的《Spring 学习笔记.pdf》</a> 4. <a href="https://mp.weixin.qq.com/s?__biz=MzkwOTAyMTY2NA==&mid=2247484544&idx=2&sn=c1dfe907cfaa5b9ae8e66fc247ccbe84&scene=21#wechat_redirect" target="_blank">阿里大佬的《MySQL 学习笔记高清.pdf》</a> 5. <a href="https://mp.weixin.qq.com/s?__biz=MzkwOTAyMTY2NA==&mid=2247485167&idx=1&sn=48d75c8e93e748235a3547f34921dfb7&scene=21#wechat_redirect" target="_blank">2021 版 java 高并发常见面试题汇总.pdf</a> 6. <a href="https://mp.weixin.qq.com/s?__biz=MzkwOTAyMTY2NA==&mid=2247485664&idx=1&sn=435f9f515a8f881642820d7790ad20ce&scene=21#wechat_redirect" target="_blank">Idea 快捷键大全.pdf</a> ![](https://itsoku.oss-cn-hangzhou.aliyuncs.com/itsoku/blog/article/1/2883e86e-3eff-404a-8943-0066e5e2b454.png)
#custom-toc-container