从Maven私服获取依赖
通过Internet直接从Maven公用仓库获取依赖包是默认配置。不过对于中国软件公司来讲,访问这些公用仓库通常较慢,对于一些管理严格的不能直接上网的软件公司来讲,这更加是不可能的。Maven项目可以配置成仅从Maven私服上获取依赖。
上一篇已经讲述了如何安装Nexus为Maven私服。下面就假定使用S1服务器上的Nexus服务。可以参考官方文档:
http://www.sonatype.com/books/nexus-book/reference/config-sect-intro.html
在开发机器上有Maven项目,首先编辑~/.m2/settings.xml.
- <settings>
- <mirrors>
- <mirror>
- <!--This sends everything else to /public -->
- <id>nexus</id>
- <mirrorOf>*</mirrorOf>
- <url>http://S1:8081/nexus/content/groups/public</url>
- </mirror>
- </mirrors>
- <profiles>
- <profile>
- <id>nexus</id>
- <!--Enable snapshots for the built in central repo to direct -->
- <!--all requests to nexus via the mirror -->
- <repositories>
- <repository>
- <id>central</id>
- <url>http://central</url>
- <releases><enabled>true</enabled></releases>
- <snapshots><enabled>true</enabled></snapshots>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>central</id>
- <url>http://central</url>
- <releases><enabled>true</enabled></releases>
- <snapshots><enabled>true</enabled></snapshots>
- </pluginRepository>
- </pluginRepositories>
- </profile>
- </profiles>
- <activeProfiles>
- <!--make the profile active all the time -->
- <activeProfile>nexus</activeProfile>
- </activeProfiles>
- </settings>
只需要把S1改成自己的Nexus服务器地址就可以了。如果你的Maven项目的pom.xml中没有自定义的repository,那么就可以使用了。比如执行mvn clean compile命令,就可从S1上下载pom.xml和jar包。
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://172.27.2.203:8081/nexus/content/groups/public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</repository>
</repositories> <pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://172.27.2.203:8081/nexus/content/groups/public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
注意,有时候nexus上已经部署了最新的snapshot,但是mvn clean compile就是不取最新版本,这时候需要用-U 参数强制检查。
mvn clean compile -U
如果还不行,则删除本地缓存的目录,在jenkins项目中可以在build之前执行一行命令,比如:
- rm -rf /usr/share/tomcat7/.m2/repository/com/esri/carrier/nginx-factory/
从Maven私服获取依赖的更多相关文章
- 将Android封装库通过gradle部署到maven私服并依赖使用
一.在需要发布的模块chrisbaselibrary下的build.gradle中添加以下部分 //maven插件 apply plugin: 'maven' //打包main目录下代码和资源的 ta ...
- Maven 私服的简单使用
所有的 Java 开发者应该是没有没用过 Maven 的吧.Maven 作为 Java 项目管理工具,它不仅可以用作包管理,还有许多的插件,可以支持整个项目的开发.打包.测试.部署等一系列行为.而包管 ...
- maven 私服同步无法获取依赖的pom.xml的依赖
项目中引入了依赖: <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hado ...
- maven仓库总结,maven私服搭建
配置pom.xml依赖包时在这里找包的描述: http://search.maven.org/#browse 以java为根目录. mvn archtype:generate -DgroupId=zt ...
- 搭建Maven私服那点事
摘要:本文主要介绍在CentOS7.1下使用nexus3.6.0搭建maven私服,以及maven私服的使用(将自己的Maven项目指定到私服地址.将第三方项目jar上传到私服供其他项目组使用) 一. ...
- [Gradle系列]Gradle发布module库到jCenter, 并构建自己的企业Maven私服
Tamic 作者: http://blog.csdn.net/sk719887916/article/details/53224544 前言 andorid开发者经常会看到xx公司发布了xx项目,xx ...
- window Maven私服搭建——nexus
注:本文来源于 <window Maven私服搭建--nexus> Maven私服搭建--nexus 1.下载nexus https://www.sonatype.com/downlo ...
- Maven的下载,安装,配置,测试,初识以及Maven私服
:Maven目录分析 bin:含有mvn运行的脚本 boot:含有plexus-classworlds类加载器框架 conf:含有settings.xml配置文件 lib:含有Maven运行时所需要的 ...
- Anroid 搭建Maven私服(Android Studio)
一.场景 ① 公司中有多个项目,多人开发,开发中的某一模块需要被其他几个项目的模块所依赖,最简单粗暴的方式就是打包成aar或者jar文件逐个拷贝到libs下进行依赖,可是这种方式太过于麻烦,而且需要每 ...
随机推荐
- Java 中的字符串(String)与C# 中字符串(string)的异同
1. C# 中比较两个字符串字面量是否相等,可以使用 “==”比较运算符,是因为string 类型重写(override)了“==” 和 “!=” 运算符,在使用“==” 和 “!=” 进行字符串比较 ...
- MyBatis 基础搭建及架构概述
目录 MyBatis 是什么? MyBatis 项目构建 MyBatis 整体架构 接口层 数据处理层 基础支持层 MyBatis 是什么? MyBatis是第一个支持自定义SQL.存储过程和高级映射 ...
- 关于在使用scrapy-redis分布式踩过的那些坑:
自己的案列:win7上安装ubuntu (win7作为slaver,ubuntu作为master ) 修改配置文件redis.conf 1)打开配置文件把下面对应的注释掉 # bind 127.0.0 ...
- wcf服务编程(一)
步骤一:定义契约 [ServiceContract] //定义服务契约 需要引用System.ServiceModel public interface ICalculator { [Operatio ...
- 哈工大计算机网络Week0-概述
目录 L01什么是计算机网络 计算机网络 Internet L02什么是网络协议? 定义 内容 三要素 L03计算机网络结构 网络边缘 接入网络 数字用户线路DSL 电缆网络 无线接入网络 网络核心( ...
- Spring MVC源码(三) ----- @RequestBody和@ResponseBody原理解析
概述 在SpringMVC的使用时,往往会用到@RequestBody和@ResponseBody两个注解,尤其是处理ajax请求必然要使用@ResponseBody注解.这两个注解对应着Contro ...
- signed char类型取值范围计算
在C语言程序中,给定一个类型,如何计算这个类型变量的取值范围呢?比如有一个字符型变量定义如下: signed char c: 这个字符变量c的取值范围是[-128,127],是计算出来的呢? 假设字符 ...
- 设计模式——通用泛型单例(普通型和继承自MonoBehaviour)
单例模式是设计模式中最为常见的,不多解释了.但应该尽量避免使用,一般全局管理类才使用单例. 普通泛型单例: public abstract class Singleton<T> where ...
- 【bfs基础】①
bfs,即广度优先搜索,主要通过队列(queue)进行操作. 稍微解释一下,队列是一种基础数据结构,其形态类似于一支长长的队伍,大概如下: 在C++中,队列的头文件定义为:#include<qu ...
- mui.storage 将数据持久化到本地
在一个用mui做得app中,要求把历史记录放在本地(感觉...无法言喻的sd),但最终还是做了,以下来记录本次的学习到的内容 mui.plusReady(function() { //这里是一开始定义 ...