针对公司内网私服仓库,私服仓库不能访问外网,此时无法在私服仓库代理阿里的maven仓库。我们的maven就需要配置多个仓库:

maven目录下的conf/settings.xml配置文件:

一、在profiles标签内新建profile,配置一个公司的仓库和阿里的仓库;

    <profile>
<id>nexus</id>
<repositories>
<!-- 私服发布仓库,即私服正式jar仓库 -->
<repository>
<id>maven-releases</id>
<url>http://192.168.0.54:8899/ajco/repository/maven-releases/</url>
</repository>
<!-- 私服快照仓库,即私服临时jar仓库 -->
<repository>
<id>maven-snapshots</id>
<url>http://192.168.0.54:8899/ajco/repository/maven-snapshots/</url>
</repository>
</repositories>
<!-- 私服插件仓库,一般插件都是从外网仓库下载,可以不用配置 -->
<pluginRepositories>
<pluginRepository>
<id>maven-releases</id>
<url>http://192.168.0.54:8899/ajco/repository/maven-releases/</url>
</pluginRepository>
<pluginRepository>
<id>maven-snapshots</id>
<url>http://192.168.0.54:8899/ajco/repository/maven-snapshots/</url>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>aliyun</id>
<repositories>
<!-- 外网仓库,用国内阿里仓库 -->
<repository>
<id>central</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>

二、在activeProfiles标签内配置activeProfile,激活上面的仓库,activeProfile里的值对应上面profile里的id值

    <activeProfile>nexus</activeProfile>
<activeProfile>aliyun</activeProfile>

说明:

1.maven有个默认的外网中央仓库,id是central。在mirrors标签内配置一个mirrorOf=central的镜像,则使用这个镜像地址替换这个外网中央仓库;

2.profiles标签里的aliyun的仓库也可以不用配置,直接在mirrors标签内配置一个镜像仓库,mirrors镜像仓库mirrorOf的值设置为central,则也可以实现覆盖默认的仓库

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

配置maven deploy:

如果需要将本地项目deploy打包上传到私服仓库,则需要配置如下信息:

一、在settings.xml的servers标签内新建server标签,定义一个登录私服的账号密码配置;

    <server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>

二、项目的pom.xml文件加入如下配置,id对应上面的server里的id,表示deploy时上传到下面的仓库,用上面的账号密码;

说明:本地项目version如果以-snapshots结尾,maven则自动选择上传到snapshotRepository仓库,即配置的快照仓库,否则上传到发布仓库。

    <distributionManagement>
<repository>
<id>deploymentRepo</id>
<url>http://192.168.0.54:8899/ajco/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>deploymentRepo</id>
<url>http://192.168.0.54:8899/ajco/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>

maven多仓库配置 公司仓库和阿里仓库的更多相关文章

  1. 创建yum本地仓库,将阿里仓库同步到本地,并定时更新

    很多时候为了加速自己内部的rpm包安装速度,都会搭建自己的yum源仓库,而使用系统光盘自带的源,由于软件版本比较落后,所以不太适用,而大家都在用的阿里仓库比较好用,所以就想到了把阿里仓库的rpm全部拉 ...

  2. maven多仓库配置(公司服务器与阿里云仓库)

    1. 问题描述 公司内网搭建的有maven私有服务器,但是碰到好几次只有gav没有jar的情况或者最新版本更新不及时,所以需要公司服务器和远程仓库(阿里云)相结合来满足项目需求. 2. 解决方案: m ...

  3. Maven多仓库配置(公司仓库和阿里云仓库)

    Maven多仓库配置(公司仓库和阿里云仓库) 一.之前的配置 之前maven本地的setting.xml的仓库配置,都是直接设置mirror节点 <mirrors> <mirror& ...

  4. 阿里云Maven配置,Maven仓库配置,Maven镜像配置

    阿里云Maven配置,Maven仓库配置,Maven镜像配置 ======================== 蕃薯耀 2018年1月29日 http://www.cnblogs.com/fanshu ...

  5. Maven settings.xml配置(指定本地仓库、阿里云镜像设置)

    转: 详解Maven settings.xml配置(指定本地仓库.阿里云镜像设置) 更新时间:2018年12月18日 11:14:45   作者:AmaniZ   我要评论   一.settings. ...

  6. 阿里云Maven仓库配置,Maven镜像配置

    Jenkins通过maven对java代码打包编译时,速度太慢,所以修改为阿里的Maven仓库 修改如下: [root@7mini-node2 conf]# vim /software/apache- ...

  7. maven与gradle的阿里云仓库配置

    直接参考 https://help.aliyun.com/document_detail/102512.html 就好. 阿里云maven仓库官网 https://maven.aliyun.com/m ...

  8. 阿里云Maven中央仓库配置

    方式一:统一配置 在maven安装目录/conf下的settings.xml 文件里配置mirrors的子节点,添加如下mirror <mirror> <id>alimaven ...

  9. (三)Maven仓库介绍与本地仓库配置

    1.Maven本地仓库/远程仓库的基本介绍 示意图: 本地仓库是指存在于我们本机的仓库,在我们加入依赖时候,首先会跑到我们的本地仓库去找,如果找不到则会跑到远程仓库中去找.对于依赖的包大家可以从这个地 ...

随机推荐

  1. JavaScript基础5

    字符串操作方法和属性 length   获取字符串的长度 str.chartAt(指定字符的索引)  获取指定位置的字符 返回string类型的值 str.concat(字符串)   链接多个字符串  ...

  2. Rest微服务案例

    数据库 数据库名称为Product; 创建api子工程,项目名为springcloud_api Product实体类 public class Product implements Serializa ...

  3. dubbo服务治理框架

    Dubbo的概述 1.1. Dubbo的背景 随着互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式服务架构以及流动计算架构势在必行,亟需一个治理系统确保架构有条不紊的演进. ...

  4. Day 02 计算机的基本组成及工作原理

    目录 计算机的构成 CPU 控制器 运算器 存储器 内存 外存 I/O (input & output) 输入设备 输出设备 什么是编程语言 什么是编程 为什么要编程 多核CPU 32位和64 ...

  5. 使用jmeter进行接口测试

    目录 jmeter介绍 jmeter安装 修改UTF-8 jmeter主要测试组件 jmeter元件作用域与执行顺序 使用Jmeter进行接口测试 jmeter介绍 JMeter是Apache基金会J ...

  6. Callable接口实现线程

    public class CallableDemo { public static void main(String[] args) throws Exception, ExecutionExcept ...

  7. Django day03之表设计分析

    models.py文件中创建表字段分析实例: 图书管理系统---> 书.作者.出版社作为基表 from django.db import models # Create your models ...

  8. jquery查出元素名称

    <div onclick='$(this).prop("tagName")'></div> 最后的结果 DIV

  9. 重构 JAVA 聊天室 —— CS 模式的简单架构实现

    前言 自从开始弄起数据挖掘之后,已经很久没写过技术类的博客了,最近学校 JAVA 课设要求实现一个聊天室,想想去年自己已经写了一个了,但是有些要求到的功能我也没实现,但看着原有的代码想了想加功能好像有 ...

  10. C#线程学习笔记七:Task详细用法

    一.Task类简介: Task类是在.NET Framework 4.0中提供的新功能,主要用于异步操作的控制.它比Thread和ThreadPool提供了更为强大的功能,并且更方便使用. Task和 ...