--------------------siwuxie095

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

配置
Maven
从私服下载构件

 
 

 
 


Nexus 私服下载构件的配置方法共有三种

 
 

1、法一:

 
 


pom.xml 的 project 标签中添加如下内容

 
 

<repositories>

<repository>

 

<id>nexus</id>

<name>Nexus</name>

<url>http://localhost:8081/nexus/content/groups/public/</url>

 

<releases>

<enabled>true</enabled>

</releases>

 

<snapshots>

<enabled>true</enabled>

</snapshots>

 

</repository>

</repositories>

 

<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

 

<pluginRepositories>

<pluginRepository>

 

<id>nexus</id>

<name>Nexus</name>

<url>http://localhost:8081/nexus/content/groups/public/</url>

 

<releases>

<enabled>true</enabled>

</releases>

 

<snapshots>

<enabled>true</enabled>

</snapshots>

 

</pluginRepository>

</pluginRepositories>

 
 

注:分别配置仓库和插件仓库

 
 

 
 

 
 

 
 

2、法二:

 
 

(1)在
settings.xml 的 profiles 标签中添加如下内容

 
 

<profile>

 

<id>nexus</id>

 
 

<repositories>

<repository>

 
 

<id>nexus</id>

<name>Nexus</name>

<url>http://localhost:8081/nexus/content/groups/public/</url>

 

<releases>

<enabled>true</enabled>

</releases>

 

<snapshots>

<enabled>true</enabled>

</snapshots>

 
 

</repository>

</repositories>

 
 

<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

 
 

<pluginRepositories>

<pluginRepository>

 
 

<id>nexus</id>

<name>Nexus</name>

<url>http://localhost:8081/nexus/content/groups/public/</url>

 
 

<releases>

<enabled>true</enabled>

</releases>

 

<snapshots>

<enabled>true</enabled>

</snapshots>

 
 

</pluginRepository>

</pluginRepositories>

 
 

</profile>

 
 

注:使用
id 为 nexus 的 profile 分别配置仓库和插件仓库

 
 

 
 

 
 

(2)在
settings.xml 的 activeProfiles 标签中添加如下内容

 
 

<activeProfile>nexus</activeProfile>

 
 

注:将
id 为 nexus 的 profile 激活

 
 

 
 

 
 

 
 

3、法三(建议):

 
 

(1)在
settings.xml 的 mirrors 标签中添加如下内容

 
 

<mirror>

<id>nexus</id>

<name>Nexus</name>

<url>http://localhost:8081/nexus/content/groups/public/</url>

<mirrorOf>*</mirrorOf>

</mirror>

 
 

注:配置一个匹配任何仓库的镜像,其地址为
Nexus 私服

 
 

 
 

 
 

(2)在
settings.xml 的 profiles 标签中添加如下内容

 
 

<profile>

 

<id>nexus</id>

 
 

<repositories>

<repository>

 
 

<id>central</id>

<name>Central</name>

<url>http://central</url>

 

<releases>

<enabled>true</enabled>

</releases>

 

<snapshots>

<enabled>true</enabled>

</snapshots>

 
 

</repository>

</repositories>

 
 

<!-- ++++++++++++++++++++++++++ -->

 
 

<pluginRepositories>

<pluginRepository>

 
 

<id>central</id>

<name>Central</name>

<url>http://central</url>

 
 

<releases>

<enabled>true</enabled>

</releases>

 

<snapshots>

<enabled>true</enabled>

</snapshots>

 
 

</pluginRepository>

</pluginRepositories>

 
 

</profile>

 
 

注:使用
id 为 nexus 的 profile 分别配置仓库和插件仓库,

但仓库和插件仓库的
id 都为 central,这将覆盖超级 POM

中央仓库的配置,而 url 已无关紧要,因为所有的请求都会

通过镜像访问私服地址

 
 

配置仓库和插件仓库的主要目的是开启对快照版本构件下载

的支持

 
 

 
 

 
 

(3)在
settings.xml 的 activeProfiles 标签中添加如下内容

 
 

<activeProfile>nexus</activeProfile>

 
 

注:将
id 为 nexus 的 profile 激活

 
 

 
 

 
 

 
 

 
 

附:

 
 

法一

针对当前
Maven 项目

法二

针对所有
Maven 项目

法三

针对所有
Maven 项目

 
 

 
 

法二和法三虽然都可以一劳永逸,但法二除了从
Nexus 私服

下载构件之外,还会不时访问中央仓库

 
 

我们希望的是所有
Maven 下载请求都仅仅通过 Nexus 私服,

以全面发挥私服的作用,而法三刚好做到了这点

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

【made by siwuxie095】

配置Maven从私服下载构件的更多相关文章

  1. 配置maven从私服上下载构件

    maven 本地setting.xml配置 <!--配置maven从私服上下载构件 --> <profiles> <profile> <repositorie ...

  2. Maven--配置 Maven 从 Nexus 下载构件

    在 POM 中配置: <project> ... <repositories> <repository> <id>nexus</id> &l ...

  3. eclipse配置maven后无法下载jar

    1.检查网络拦截是否正常 2.进入maven依赖库根目录搜索出该目录下的*lastUpdated.properties文件并删除 然后就可以继续下载jar包了

  4. NPM:如何配置maven npm私服

    https://help.sonatype.com/repomanager3/quick-start-guide-proxying-maven-and-npm#QuickStartGuide-Prox ...

  5. IntelliJ IDEA及maven、git下载与配置

    maven下载地址:http://maven.apache.org/download.cgi,下载bin文件然后解压 maven环境变量配置: MAVEN_HOME:D:  \install\apac ...

  6. maven 搭建私服

    博客参考 https://www.cnblogs.com/luotaoyeah/p/3791966.html 整理纯为技术学习 1 . 私服简介 私服是架设在局域网的一种特殊的远程仓库,目的是代理远程 ...

  7. J2EE走向成功路-02-Struts2 配置(Maven)

    在上一篇中,介绍了使用jar包搭建Struts2框架,这一篇中来介绍一下在Maven环境下搭建Struts2框架,主要为配置Maven. 1.下载Maven,官网:http://maven.apach ...

  8. IntellIJ IDEA 配置 Maven 以及 修改 默认 Repository

    转自:IntellIJ IDEA 配置 Maven 以及 修改 默认 Repository 今天将IntellIJ IDEA 关于Maven的配置总结一下,方便以后可参考. IDEA版本: Intel ...

  9. Eclipse 配置Maven以及修改默认Repository

    今天将Eclipse关于Maven的配置总结一下,方便以后配置. 一.配置Maven环境 1.下载apache-maven文件,选择自己需要的版本,地址:http://mirrors.cnnic.cn ...

随机推荐

  1. 转载-java基础学习汇总

    共2页: 1 2 下一页  Java制作证书的工具keytool用法总结 孤傲苍狼 2014-06-24 11:03 阅读:25751 评论:3     Java基础学习总结——Java对象的序列化和 ...

  2. java中使HttpDelete可以发送body信息

    java中使HttpDelete可以发送body信息RESTful api中用到了DELETE方法,android开发的同事遇到了问题,使用HttpDelete执行DELETE操作的时候,不能携带bo ...

  3. 1037 Magic Coupon (25 分)

    1037 Magic Coupon (25 分) The magic shop in Mars is offering some magic coupons. Each coupon has an i ...

  4. JNDI的学习与使用

    JNDI(Java Naming and Directory Interface,Java命名和目录接口)是一组在Java应用中访问命名和目录服务的API.命名服务将名称和对象联系起来,使得我们可以用 ...

  5. 第14章 UDP编程(1)_UDP客户端服务器模型

    1. UDP编程模型 (1)UDP客户端服务器模型 ①客户端可以不调用bind()而直接与服务器通讯. ②UDP是无连接的,因此服务端不需要调用accept和listen,客户端也无需调用connec ...

  6. js的数组操作相关(BigTree*)

    JavaScript中创建数组有两种方式 (一)使用 Array 构造函数: var arr1 = new Array(); //创建一个空数组var arr2 = new Array(20); // ...

  7. 常用数据库2 sqlite及SQL注入

    知识内容: 1.sqlite数据库介绍 2.sqlite数据库操作 3.SQL注入 一.sqlite数据库介绍 1.sqlite数据库 sqlite数据库:轻量级的数据库,一般开发中使用sqlite数 ...

  8. tornado-简单的服务器

    安装tornado pip install tornado 安装sqlalchemy 1.大概代码的解释 import tornado.ioloop #开启循环,等待访问 import tornado ...

  9. Javascript,获取元素,write方法

    一:Javascript:弱类型脚本语言,是一种动态类型.实现部分动画效果和用户交互等 -- html是骨架(页面结构)  css样式  js是行为 -- 弱类型体现: JS代码可以写在body,he ...

  10. 代码:cookie(一个广告展示例子)

    这个小例子的要求是: 用户第一次进入,显示大图,2秒后大图动画关闭,再把小图动画展开: 用户再次进入后,只显示静态小图. 做法: 定义一个容器 .img201512ad,宽高写死:1190x70.—— ...