使用IDEA打包上传到Nexus3私服

  • 一、Nexus是什么
  • 二、使用Nexus3搭建maven私服
  • 三、IDEA打包上传到Nexus3私服
    • 1.配置 .m2 下的 settings.xml
    • 1.配置 IDEA 项目 下的 pom.xml
    • 3.配置上传地址,地址去私服中copy
    • 4.其他配置(可忽略)
    • 5.settings.xml完整配置(来源网络,仅供参考)
    • 6.IDEA打包上传

一、Nexus是什么

开始在使用Maven时,总是会听到nexus这个词,一会儿maven,一会儿nexus,为什么它总是和maven一起被提到呢?

Maven作为一个优秀的构建工具依赖管理工具项目信息管理工具,在进行依赖管理的时候,通过pom.xml里面的

<dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.1.0</version>
</dependency>

来精准定位找到对应的Java类库。在这个过程当中我们需要从仓库去找到对应的jar包引入到我们的项目当中,由此我们解决了合作开发中依赖增多、版本不一致、版本冲突、依赖臃肿等问题。

Maven有本地仓库远程仓库两种,当Maven根据坐标寻找构件时,它首先会查看本地仓库,如果本地仓库存在此构件,则直接使用;如果本地仓库不存在此构件,或者需要查看是否有更新的构件版本,Maven会去远程仓库查找,发现需要的构件之后,下载到本地仓库再使用。


说到此,相信大家也明白了,Nexus是一种远程仓库也是私服的一种

SNAPSHOT
快照版本,在 maven 中 SNAPSHOT 版本代表正式发布(release)的版本之前的开发版本,在 pom 中用 x.y-SNAPSHOT 表示。

RELEASE
发布版本,稳定版本,在 maven 中 RELEASE 代表着稳定的版本,unchange,不可改变的,在 maven 中 SNAPSHOT 与 RELEASE 版本在策略上是完全不同的方式,SNAPSHOT 会根据你的配置不同,频繁的从远程仓库更新到本地仓库;而 RELEASE 则只会在第一次下载到本地仓库,以后则会先直接从本地仓库中寻找。

二、使用Nexus3搭建maven私服

在网上找到几个参考:
Windows中使用Nexus3搭建maven私服
maven 私服 nexus3.x 搭建 与使用
Maven私服Nexus3.x环境构建操作记录

三、IDEA打包上传到Nexus3私服

1.配置 .m2 下的 settings.xml

首先,这个文件在系统盘当前设备登录用户的.m2文件下,加入认证机制

没有就去网上copy一个配置好的,自己配置容易出错

->settings.xml<-

<servers><server><id>nexus</id><username>admin</username><password>admin123</password></server><server><id>maven-snapshots</id><username>admin</username><password>admin123</password></server><server><id>maven-releases</id><username>admin</username><password>admin123</password></server><server><id>rdc-releases</id><username>xxxxxxxxx</username><password>xxxxx</password></server><server><id>rdc-snapshots</id><username>xxxxxxxxx</username><password>xxxx</password></server>
</servers>

1.配置 IDEA 项目 下的 pom.xml

 <distributionManagement><repository><id>nexus</id><name>nexus</name><url>http://xxxx:port/repository/maven-snapshots/</url></repository><snapshotRepository><id>maven-snapshots</id><name>maven-snapshots</name><url>http://xxxx:port/repository/maven-snapshots/</url></snapshotRepository></distributionManagement>

这里标签中的id对应第一条server中的id ,url取得值可以直接在这里写,也可以如下图中settings文件中的值,name可以自定义
->settings.xml<-

<profile><altReleaseDeploymentRepository> http://xxxx:port/repository/maven-snapshots/ </altReleaseDeploymentRepository><altSnapshotDeploymentRepository> http://xxxx:port/repository/maven-snapshots/</altSnapshotDeploymentRepository>
</profile>

同样,上面pom.xml改成如下格式

<distributionManagement><repository><id>nexus</id><name>nexus</name><url>${altReleaseDeploymentRepository}</url></repository><snapshotRepository><id>maven-snapshots</id><name>maven-snapshots</name><url>${altSnapshotDeploymentRepository}</url></snapshotRepository></distributionManagement>

3.配置上传地址,地址去私服中copy

<profile> <!--profile 的 id--><id>dev</id> <repositories> <repository> <!--仓库 id,repositories 可以配置多个仓库,保证 id 不重复--><id>nexus</id> <!--仓库地址,即 nexus 仓库组的地址--><url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下载 releases 构件--><releases> <enabled>true</enabled> </releases> <!--是否下载 snapshots 构件--><snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <!-- 插件仓库,maven 的运行依赖插件,也需要从私服下载插件 --><pluginRepository> <!-- 插件仓库的 id 不允许重复,如果重复后边配置会覆盖前边 --><id>central</id> <name>Nexus Plugin Repository</name> <url>http://central</url> <releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository> </pluginRepositories>
</profile>

4.其他配置(可忽略)

比如配置阿里的镜像,映射阿里中央仓库(下载jar包快一点)

<mirrors><mirror><id>alimaven</id><name>aliyun maven</name><url>http://maven.aliyun.com/nexus/content/groups/public/</url><mirrorOf>central</mirrorOf>       </mirror>
</mirrors>

配置本地仓库(无需联网使用jar包)

<localRepository>E:\maven_repository</localRepository>

5.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>D:\mvn_repo\repository</localRepository><!-- 以下配置为上传jar包配置 --><pluginGroups></pluginGroups><proxies></proxies><servers><server><!-- id,对应项目里面pom.xml里面distributionManagement配置的id --><id>maven-releases</id><!-- 登录nexus的用户名 --><username>admin</username><!-- 登录nexus的密码 --><password>admin123</password></server><server><!-- id,对应项目里面pom.xml里面distributionManagement配置的id --><id>maven-snapshots</id><!-- 登录nexus的用户名 --><username>admin</username><!-- 登录nexus的密码 --><password>admin123</password></server><!-- 配置拦截器mirror登录的用户名密码。他会拦截所有的请求到mirror指定的地址下载jar包 如果只需要去私服下载jar包则只需配置此项 --><server><!-- id,对应mirror中id --><id>nexus</id><username>admin</username><password>admin123</password></server></servers><!-- 以下配置为下载jar包配置 通用 --><mirrors><!-- 强制让jar包下载走私服 --><mirror><id>nexus</id><mirrorOf>*</mirrorOf><url>http://192.168.65.129:8081/repository/maven-public/</url></mirror></mirrors><profiles><profile><!-- 对应activeProfiles-activeProfile的内容 --><id>nexus</id><!-- 仓库地址 --><repositories><repository><!-- 私服id,覆盖maven-model模块下的父id,让maven不走中央仓库下载,走私服下载 --><id>central</id><!-- 名字 --><name>Nexus</name><!-- 私服地址,写central后,会去mirror里面找 --><url>http://central</url><!-- 支持releases版本 --><releases><enabled>true</enabled></releases><!-- 支持snapshots版本 --><snapshots><enabled>true</enabled></snapshots></repository></repositories><!-- 插件地址 --><pluginRepositories><pluginRepository><id>central</id><name>Nexus Plugin Repository</name><url>http://central</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository></pluginRepositories><!-- 配置全局的url地址 供上传jar包时动态获取 --><properties><ReleaseRepository>http://192.168.65.129:8081/repository/maven-releases/</ReleaseRepository><SnapshotRepository>http://192.168.65.129:8081/repository/maven-snapshots/</SnapshotRepository></properties></profile></profiles><!-- 选择使用的profile --><activeProfiles><activeProfile>nexus</activeProfile><!-- <activeProfile>rdc</activeProfile>--></activeProfiles></settings>

6.IDEA打包上传

使用idea打包,打包时会根据pom文件中version判断是快照版本还是发布版本,version中0.0.1-SNAPSHOT 带SNAPSHOT为快照版本,删掉SNAPSHOT为发布版本,上传到私服时根据version自动判断上传到哪个仓库

注意,打包时 项目的pom文件一定要把maven-plugin删除掉,不然打包完成后会生成BOOT-INF文件夹,会造成上传到私服后,配置依赖后能下载到jar包,但是使用时报包找不到错误

 <version>1.1-SNAPSHOT</version><build></build>

然后clean后deploy

看到BUILD SUCCESS的提示则为成功,可以在自己私服上查看

Nexus简介及小白使用IDEA打包上传到Nexus3私服详细教程相关推荐

  1. Github上传代码菜鸟超详细教程

    最近需要将课设代码上传到Github上,之前只是用来fork别人的代码. 这篇文章写得是windows下的使用方法. 第一步:创建Github新账户 第二步:新建仓库 第三部:填写名称,简介(可选), ...

  2. bugly上传符号表文件详细教程

    1.下载上传符号表工具 https://bugly.qq.com/v2/downloads 2.在终端 进入到 buglyqq-upload-symbol.jar 文件夹中 3 执行命令 java - ...

  3. html七牛云图片文件上传,使用Js将文件图片视频上传到七牛云详细教程-Fun言

    前言 因为项目需要,需要将一些较大文件上传到七牛云,以前都是通过数据流上传到服务端,然后在服务端进行上传操作,因为以前文件都很小所以无所谓,但是要是几百M的文件就不行了,所以就采用前端js直接上传到七 ...

  4. 发布你自己的轮子 - PyPI打包上传实践

    文章目录 发布 Python 包 准备 创建用户验证文件 创建项目结构 编写setup.py 编写README.md 编写LICENSE 生成发布包 本地测试(可选) 上传到PyPI 安装测试 常见错 ...

  5. Springboot 项目打包上传到私服 Nexus3,如何通过私服下载自己上传的jar包,Nexus3的搭建和使用(二)

    上一篇写了私服的搭建和登录后的界面介绍,这一篇具体写一下私服的使用,如何通过私服下载工程依赖,如何上传自己项目为其他工程项目引用. 一,如何通过私服下载项目工程依赖 下面的图是登录之后的界面,主要是第 ...

  6. 如何用微信web开发者工具测试调试并打包上传小程序

    厦门四六开科技给大家讲讲 如何用微信web开发者工具测试调试并打包上传小程序,其实还是很简单的,这个教程针对小白,大神请直接略过. 一.下载并安装软件(根据自己电脑实际情况选择版本安装) 如何用微信开 ...

  7. cordova media android不播放声音,cordova-plugin-media 录音并打包上传

    一.录音. 插件:cordova-plugin-media 官网中的示例代码很详细了,src可以为"cdvfile://localhost/persistent/"的形式,但我未能 ...

  8. ios 构建版本一直在处理中_iOS -打包上传成功,在构建版本一直刷不出来

    今天提交版本到appstore,构建版本一直不出来,等了一天也没有出来,其实就是权限问题,iOS13 来了,所以面临的问题随之而来,苹果给邮箱发了这段话: Dear Developer,We iden ...

  9. iOS开发之打包上传报错: ERROR ITMS-90087/ERROR ITMS-90125

    制作好的framework在打包上传至AppStore如果出现以下错误,则说明这个SDK里面包含了x86_64, i386 架构,当然这个AppStore是不允许的,所以会在上传的时候报错,解决办法就 ...

最新文章

  1. 超实用 Linux下通过VNC安装Oracle
  2. DBA(四):数据读写分离,MySQL多实例操作
  3. 根据这博客复习,我收到了BAT等大厂的技术岗offer
  4. java调用打印预览_急求一个用Java实现的打印及打印预览功能的Demo
  5. Selector的一些state使用
  6. 如何避免向下传递回调?
  7. js配置打印机属性_你还在为如何设置打印机而烦恼吗?一招教你快速共享打印机!...
  8. 计算机Word2010在线做题,Word2010题库(答案)试题.doc
  9. 人生如何尽兴呢? 举头天外望,无我这般人「陆九渊」,“惟天下至诚,为能尽其性”...
  10. wangEditor富文本编辑器自定义图片上传
  11. 第九届全国大学生GIS应用技能大赛下午(试题及参考答案含数据)
  12. 阿里云服务器使用docker安装mysql
  13. 电脑程序是如何运行起来的
  14. 数据驱动运营,为门店开拓第二增长曲线。
  15. 【数学】第一型曲线积分
  16. Linux命令之投影密码开启和关闭命令
  17. 高等工程数学(张韵华,汪琥庭,宋立功)—— 第二篇:数值计算
  18. 【软件测试】接口测试工具Charles之map remote setting
  19. 《Python爬虫100例》复盘⑦,解决手机APP爬虫环境问题
  20. DevOps成就卓越

热门文章

  1. 第四周项目3单链表应用(2)
  2. MemCache详解
  3. 华为认证Datacom考试内容
  4. HSQLDB数据库使用详解(入门)及快速使用
  5. 麻省理工学院计算机科学,麻省理工学院素以世界顶尖的工程学和计算机科学而享誉世界[1-2] ,位列2015-16年世...
  6. 通过路由器访问光猫(openwrt)
  7. Coding and Paper Letter(八十七)
  8. 计算机网络题库——第3章数据链路层
  9. 乐动手环app下载安装_乐动健康安卓版
  10. pr零基础晋升笔记(学习复习用)