Nexus安装配置
一、下载最新版本的nexus
1、下载地址:http://www.sonatype.org/nexus/go
2、官网如果下载不了,就找个zip下载,我下载的是:nexus-2.10.0-02-bundle.zip
3、 解压zip文件,出现两个文件夹:
4、 打开D:\tools\Nexus-oss\nexus-2.10.0-02\bin\jsw\,选择合适的系统,打开对应的文件夹:
二、安装nexus
1、安装
点击install-nexus.bat,然后访问http://localhost:8081/nexus/ 启动后如下页面,在右上角有个Log in 的超链接,点击登录
默认的用户名是 admin 密码是 admin123
2、修改登录信息:
3、配置代理
配置一下maven的代理服务器(前提是你的电脑不能连接外网,如果可以上外网,这里也没有意思,只是介绍一下)
添加你的代理服务器就可以了。
4、使用3rd party
使用3rd party这个第三方的功能,将maven仓库中没有构件的jar包上传到服务器
5、修改central repo的默认地址
maven3使用nexus作为代理服务器时需要修改中央库的url地址,maven默认的中央库的地址是http://repo.maven.apache.org/maven2/,而nexus默认的中央代理库的地址是http://repo1.maven.org/maven2/,可能是maven3启用了新的中央库,解决办法是:
修改nexus的中央库central配置:
把默认的中央库的url:http://repo1.maven.org/maven2/
修改为: http://repo.maven.apache.org/maven2/
三、 在项目中配置Nexus Repository的信息
配置工程的pom.xml,使用nexus repository的jar包:
1、添加本地仓库地址
在Maven项目的pom.xml中添加如下的本地仓库地址:
<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://10.10.10.41:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
2、添加插件仓库地址:
在Maven项目的pom.xml中添加如下的本地仓库地址:
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>nexus</name>
<url>http://10.10.10.41:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
3、分发构件至远程仓库
mvn install 会将项目生成的构件安装到本地Maven仓库,mvn deploy 用来将项目生成的构件分发到远程Maven仓库。本地Maven仓库的构件只能供当前用户使用,在分发到远程Maven仓库之后,所有能访问该仓库的用户都能使用你的构件。
所以我们需要配置工程中POM的distributionManagement来指定Maven分发构件的位置
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://10.10.10.41:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://10.10.10.41:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
四、用Nexus Repository取代Maven Central Repository
配置maven的settings.xml文件
4.1、文件存放位置
全局配置: ${M2_HOME}/conf/settings.xml
用户配置: ${user.home}/.m2/settings.xml
备注:用户配置优先于全局配置。${user.home} 和和所有其他系统属性只能在3.0+版本上使用。请注意windows和Linux使用变量的区别。
4.2、配置server
<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
备注:settings.xml中server元素下id的值必须与POM中repository下id的值完全一致。将认证信息放到settings下而非POM中,是因为POM往往是他人可见的,而settings.xml是本地的。
4.3、用Nexus取代Maven Central Repository
目前我们只是创建了一个专属的Nexus Repository,我们的项目默认还是使用的Maven Central Repository,所以这时我们需要将Maven Central Repository换成自己创建的Nexus Repository,可以通过修改~/.m2/settings.xml来达到这样的目的。
在settings.xml文件中(没有的话可以创建一个),加入以下配置:
<mirrors>
<mirror>
<id>nexus-releases</id>
<mirrorOf>*</mirrorOf>
<url>http://10.10.10.41:8081/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>nexus-snapshots</id>
<mirrorOf>*</mirrorOf>
<url>http://10.10.10.41:8081/nexus/content/groups/public-snapshots</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>releases</id>
<url>http://10.10.10.41:8081/nexus/content/repositories/releases</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://10.10.10.41:8081/nexus/content/repositories/snapshots</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>releases</id>
<url>http://10.10.10.41:8081/nexus/content/repositories/releases</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>http://10.10.10.41:8081/nexus/content/repositories/snapshots</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
以上配置通过mirror和profile的方式将central Repository全部转向到我们自己的Public Repositories,包括release版本和snapshot版本(Maven默认允许从Maven Central Repository下载release版本,这是合理的,如果你使用了别人的snapshot版本,一边你在使用,一边别人在开发,别人将API签名一换,你就悲剧了)。这样一来,我们项目中的所有依赖都从Nexus的Public Repositories下载,由于其中包含了对Maven Central Repository的代理,所以此时Maven Central Repository中的类库也是可以间接下载到的。此时你可以将~/.m2/repository/中所有的内容删除掉,再在项目中执行“mvn clean install”,你将在终端中看到Maven已经开始从Nexus 的Public Repositories中下载依赖了。
OK,完成了nexus私服的搭建,项目组开发人员开发时,只要在项目的pom.xml文件中,添加如下pom.xml信息即可获取私服的jar.
如果添加其他的构件时,会先在nexus中下载好,以后才会下载到本地。以后,如果发现nexus已经存在某一jar包,则会直接从nexus下载,如果没有再去网络上下载。这就是搭建nexus的好处。
所以很有必要搭建nexus。
五、FAQ
5.1、was cached in the local repository
5.1.1、问题描述:
在使用maven私服仓库编译项目时,由于缺少jar包编译失败,然后上传缺失的jar包至nexus私服仓库,但是编译还失败了,
出现错误:was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
5.1.2、问题原因:
Maven默认会使用本地缓存的库来编译工程,对于上次下载失败的库,maven会在~/.m2/repository/ / / /目录下创建xxx.lastUpdated文件
5.1.3、解决办法:
删除~/.m2/repository/ / / /目录下的*.lastUpdated文件,然后再次编译工程
Nexus安装配置的更多相关文章
- Nexus安装配置和使用
Nexus安装配置和使用 第一步安装jdk yum install java-1.8.0-openjdk-devel 第二步下载nexus-3.12.1-01-unix.tar.gzjdk 下载地址: ...
- nexus 安装配置
一.下载Nexus http://nexus.sonatype.org/downloads 我是用的版本是 nexus-2.11.4-01-bundle.tar.gz 每个版本的配置有些许差别. 二. ...
- Nexus 安装配置教程
目录 为什么使用 Nexus Docker 模式安装 Nexus 使用 data volume 使用本地目录 Nexus 配置 配置 Blob Stores Nexus 使用 包下载 包上传 参考 为 ...
- centos安装配置和使用 Nexus
Nexus安装配置和使用 第一步安装jdk yum install java-1.8.0-openjdk-devel 第二步下载nexus-3.12.1-01-unix.tar.gzjdk 下载地址: ...
- Linux下安装配置Nexus
一.安装和运行nexus 1.下载nexus:http://www.sonatype.org/nexus/go 可选择tgz和zip格式,以及war,选择tgz或zip时不同版本可能在启动时存在一定问 ...
- 1.Nexus安装与配置
1.Nexus下载下载地址:http://www.sonatype.org/nexus/go/下载后的文件:nexus-2.11.4-01-bundle.zip安装:直接解压到某个目录即可解压后,会有 ...
- Maven仓库Nexus的安装配置
1.下载nexus,最新版本是nexus-2.8.0-05 参考文章 下载nexus-latest-bundle.zip文件后,并解压到 D:\nexus下 配置nexus的环境变量:先配置NE ...
- Linux 安装配置maven3.0 以及搭建nexus私服
http://carvin.iteye.com/blog/785365 一.软件准备 1.apache-maven-3.0-bin.tar.gz 下载地址:http://www.apache.org/ ...
- linux 安装配置nexus以及maven私服应用
---------------------nexus---------------------- 1.编辑nexus脚本, 配置 RUN_AS_USER 参数vi /usr/local/src/nex ...
随机推荐
- Android 7.1 App Shortcuts使用
Android 7.1 App Shortcuts使用 Android 7.1已经发了预览版, 这里是API Overview: API overview. 其中App Shortcuts是新提供的一 ...
- React Native 之 组件化开发
前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...
- webView 自适应高度 document.body 属性
前段时间开发遇到webView 高度自适应问题,用最初的方法无效,找了些资料,记录下. 1.若网页中含有< !DOCTYPE html PUBLIC "-//W3C//DTD XHTM ...
- 最新Android系统版本与API等级对应关系表
最新Android系统版本与API等级对应关系表 从Android官网拷过来的,方便查阅... 官网地址:https://developer.android.com/guide/topics/mani ...
- 自动化集成部署udeployer 批量统一安装一键部署
通过jenkins构建项目:version版本控制:udployer自动化集成:ucop业务巡检做到高效高可用的自动化体系. 1.0版本: 逻辑与业务分离,完美实现逻辑与业务分离,业务实现统一sh ...
- 用 JSP 实现对文件的相关操作
前段时间一直忙着作业,实验,动手的时间真是少之又少,今天终于可以继续和大家分享关于 JSP 的学习心得. 简单总结一下吧: JSP 理论性很强,感觉就是纯语法. 我更偏向于实际编写代码,这样更容易理解 ...
- [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- AppBox_v2.0完整版免费下载,暨AppBox_v3.0正式发布!
文章更新: AppBox v6.0中实现子页面和父页面的复杂交互 AppBox 是基于 FineUI 的通用权限管理框架,包括用户管理.职称管理.部门管理.角色管理.角色权限管理等模块. AppBox ...
- WinRAR5.4
Winrar是一款优秀的压缩解压工具! 免费版 :http://www.winrar.com.cn/ ###加载启动广告,支持正版 海阔天空:http://pan ...
- 【WPF】Combobox指定选中值用selectedValue不是很灵的时候,
wpf combobox 指定选中的值,前题,combobox是通过数据库绑定的ItemsSource:所以再指定的时候用selectValue不是很成功!我的解决方法是 生成一个字典,办值和索引对应 ...