1.hosted,宿主仓库,部署自己的jar到这个类型的仓库,包括releases和snapshot两部分,Releases公司内部发布版本仓库、 Snapshots 公司内部测试版本仓库
2.proxy,代理仓库,用于代理远程的公共仓库,如maven中央仓库,用户连接私服,私服自动去中央仓库下载jar包或者插件。 
3.group,仓库组,用来合并多个hosted/proxy仓库,通常我们配置自己的maven连接仓库组。
4.virtual(虚拟):兼容Maven1 版本的jar或者插件 注意:nexus仓库默认在sonatype-work目录中 需求 :将ssh_dao的这个工程打成jar包,并放入到私服上去.
配置
第一步: 需要在客户端即部署dao工程的电脑上配置 maven环境,并修改 settings.xml 文件,配置连接私服的用户和密码 。 此用户名和密码用于私服校验,因为私服需要知道上传都 的账号和密码 是否和私服中的账号和密码 一致。 <server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server> releases 连接的是 发布版本项目仓库
snapshots 连接的是 测试版本项目仓库 第二步: 配置项目pom.xml
配置私服仓库的地址,本公司的自己的jar包会上传到私服的宿主仓库,根据工程的版本号决定上传到哪个宿主仓库,
如果版本为release则上传到私服的release仓库,如果版本为snapshot则上传到私服的snapshot仓库 <distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement> 注意:pom.xml这里<id> 和 Maven中的settings.xml 配置 <id> 对应! 测试
将项目dao工程打成jar包发布到私服:
1、首先启动nexus
2、对dao工程执行deploy命令

  

从私服下载jar包 

需求:
没有配置nexus之前,如果本地仓库没有,去中央仓库下载,
通常在企业中会在局域网内部署一台私服服务器,
有了私服本地项目首先去本地仓库找jar,
如果没有找到则连接私服从私服下载jar包,
如果私服没有jar包私服同时作为代理服务器从中央仓库下载jar包,
这样做的好处是一方面由私服对公司
项目的依赖jar包统一管理,一方面提高下载速度,
项目连接私服下载jar包的速度要比项目连接中央仓库的速度快的多。 本例子测试从私服下载dao 工程jar包。
管理仓库组:
nexus中包括很多仓库,hosted中存放的是企业自己发布的jar包及第三方公司的jar包,
    proxy中存放的是中央仓库的jar,为了方便从私服
下载jar包可以将多个仓库组成一个仓库组,每个工程需要连接私服的仓库组下载jar包。 在setting.xml中配置仓库:
在客户端的Maven中setting.xml中配置私服的仓库,
   由于setting.xml中没有repositories的配置标签需要使用profile定义仓库。 <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>public</id>
<name>Public Repositories</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile> 使用profile定义仓库需要激活才可生效。 <activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles> 配置成功后通过eclipse查看有效pom,有效pom是maven软件最终使用的pom内容,程序员不直接编辑有效pom,打开有效pom 有效pom内容如下:
下边的pom内容中有两个仓库地址,maven会先从前边的仓库的找,如果找不到jar包再从下边的找,从而就实现了从私服下载jar包。
<repositories>
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>public</id>
<name>Public Repositories</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>Public Repositories</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</pluginRepository>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>

  

nexus的jar包上传与下载的更多相关文章

  1. nexus搭建maven私服及私服jar包上传和下载

    nexus搭建maven私服及私服jar包上传和下载 标签: nexus管理maven库snapshot 2017-06-28 13:02 844人阅读 评论(0) 收藏 举报 分类: Maven(1 ...

  2. 构建自己的jar包上传至Mvaen中央仓库和版本更新

    构建自己的jar包上传至Mvaen中央仓库和版本更新 一直羡慕别人制造轮子,开源项目,供别人使用:我也想这样,可以自己才疏学浅,本次就将自己写小工具上传到Maven的中央仓库. 一步一步详细教程演示如 ...

  3. Maven中安装本地Jar包到仓库中或将本地jar包上传

    摘要 maven install 本地jar 命令格式 mvn install:install-file -DgroupId=<group_name> -DartifactId=<a ...

  4. 用eclipse怎样将本地的项目打成jar包上传到maven仓库

    使用maven的项目中,有时需要把本地的项目打成jar包上传到mevan仓库. 操作如下: 前提:pom文件中配置好远程库的地址,否则会报错 1.将maven 中的settings文件配置好用户名和密 ...

  5. maven jar包上传到服务器

    maven jar包上传到服务器时出现pom文件没有上传上去,致使该jar包再被使用的时候没有依赖,jar包调用出错 解决办法,将pom文件一起deploy上去 mvn deploy:deploy-f ...

  6. Apache Flink任意Jar包上传导致远程代码执行漏洞复现

    0x00 简介 Apache Flink是由Apache软件基金会开发的开源流处理框架,其核心是用Java和Scala编写的分布式流数据流引擎.Flink以数据并行和流水线方式执行任意流数据程序,Fl ...

  7. IDEA如何将写好的java类(UDF函数)打成jar包上传linux

    一.编写一个UDF函数,实现将字符串大写转小写 import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; ...

  8. Apache Flink Dashboard未授权访问导致任意Jar包上传漏洞

    漏洞危害 攻击者无需Flink Dashboard认证,通过上传恶意jar包 csdn-[漏洞复现]Apache Flink任意Jar包上传导致远程代码执行 freebuf-Apache Flink ...

  9. 第三方jar包上传私服和项目使用

    下面只做个人日志记录,勿喜勿喷 使用两个浏览器,带着下面的问题去看:https://www.cnblogs.com/tyhj-zxp/p/7605879.html.就会清晰了 1.下载和安装nexus ...

随机推荐

  1. SpringBoot系列: Web应用鉴权思路

    ==============================web 项目鉴权============================== 主要的鉴权方式有:1. 用户名/密码鉴权, 然后通过 Sess ...

  2. .NET面试题系列(十七)前端面试

    JavaScript  js如何实现继承 CSS 行内元素和块状元素的区别   CSS让2个DIV在同一行显示的解决方法 在CSS中,div属于块级元素,每个块级元素默认占一行高度,一行内添加一个块级 ...

  3. [物理学与PDEs]第2章第1节 理想流体力学方程组 1.3 理想流体力学方程组的数学结构

    1.  局部音速 $c$: $c^2=\cfrac{\p p}{\p \rho}>0$. 2.  将理想流体力学方程组 $$\beex \bea \rho\cfrac{\p {\bf u}}{\ ...

  4. [译]Ocelot - Request Aggregation

    原文 Aggregate ReRoutes用来组合多个ReRoutes,将它们的响应结果映射到一个响应中返回给客户端. 为了使用Aggregate ReRoutes,你必须像下面的ocelot.jso ...

  5. 使用js代码将html导出为Excel

    js代码将html导出为Excel的方法: 直接上源码: <script type="text/javascript" language="javascript&q ...

  6. windows服务器基本管理及服务搭建

    windows服务器基本管理及服务搭建 ****windows服务器系统版本:2000 2003 2008 2012 1.用户与组管理 用户:账户=账号/用户名+密码 每个账户有自己唯一的SID 账户 ...

  7. 使用echarts-for-react 绘制折线图 报错:`series.type should be specified `

    解决办法: 在动态获取值的函数前面加 访问器属性  get ,去获取对象的属性 @inject('commonStore', 'reportUIStore') @observer class Line ...

  8. IDEA15 下运行Scala遇到问题以及解决办法

    为了让Scala运行起来还是很麻烦,为了大家方便,还是记录下来: 1.首先我下载的是IDEA的社区版本,版本号为15. 2.下载安装scala插件: 2.1 进入设置菜单. 2.2 点击安装JetBr ...

  9. 史上最污技术解读,让你秒懂IT术语(转载)

    假设你是一位妹子,你的男友沉迷游戏经常不接电话无故宕机,所以当你们约好下午逛街以后你要时不时地打个电话询问,看看他是不是还能正常提供服务,这叫心跳检测. 假设你是一位妹子,你想去逛街而你的男友A在打游 ...

  10. MVC中一般为什么用IQueryable而不是用IList?

    IList(IList<T>)会立即在内存里创建持久数据,这就没有实现“延期执行(deferred execution)”,如果被加载的实体有关联实体(associations),此关联实 ...