首页 技术 正文
技术 2022年11月11日
0 收藏 736 点赞 2,504 浏览 2491 个字

简介
        Nexus 可以代理并缓存 Maven 构件,当 Maven 需要下载构件的时候,就不需要反复的请求中央仓库。

有些公司都不提供外网给项目组人员,因此就不能使用 Maven 访问远程的仓库地址,所以很有必要在局域网里找一台有外网权限的机器,搭建 Nexus 私服,然后开发人员连到这台私服上,这样的话就可以通过这台搭建了 Nexus 私服的电脑访问 Maven 的远程仓库。

        这样就相当于在我们本地的局域网搭建了一个类似中央仓库的服务器,我们开始将中央仓库的一些资料下载到私服务器上,然后平时我们的 Maven 项目就是直接访问局域网内的私服即可,既节省了网络带宽也会加速项目搭建的进程,这样对我们开发来说,对公司来说都是非常好的选择。
        当然也不一定要将 Nexus 部署到内网,也可以根据需要部署到公网。
安装Nexus(Linux下)

Nexus是典型的Java Web应用,它有两种安装包,一种是包含Jetty容器的Bundle包,另一种是不包含Web容器的war包。

1. 下载

官网下载很麻烦,这里有下好的Bundle包(链接:http://pan.baidu.com/s/1c0hfJY4 密码:vw83)

2. 安装

# tar xzvf nexus-oss-webapp-1.8.0-bundle.tar.gz

3. 启动

进入cd  /usr/nexus/nexus-2.11.2-06/bin

./nexus start

(输入./nexus 回车可以查看其他命令Usage: ./nexus { console | start | stop | restart | status | dump } )

nexus默认监听的端口是8081。那么我们就可以在浏览器中访问:http://host:8081/nexus

配置Nexus

默认的用户名和密码:admin/admin123(一般登陆以后要修改密码),端口如果有冲突可以在/usr/nexus/nexus-2.11.2-06/conf的nexus.properties里面修改,下面是一些必要的配置(把索引打开)

本地使用Nexus

Maven安装可以参考 有道:Maven 介绍、安装使用

settings.xml 配置私服地址

1234567891011121314151617181920212223242526272829303132333435363738394041 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"           xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">     <localRepository>${MAVEN_HOME}/repository</localRepository>   <profiles>      <profile>       <id>dev</id>          <repositories>             <repository>                 <id>nexus</id>                 <url>http://xx.xx.xx.xx:8181/nexus/content/groups/public/</url>                 <releases>                    <enabled>true</enabled>                 </releases>                 <snapshots>                    <enabled>true</enabled>                 </snapshots>              </repository>            </repositories>                       <pluginRepositories>                <pluginRepository>                    <id>nexus</id>                    <url>http://xx.xx.xx.xx:8181/nexus/content/groups/public/</url>                    <releases>                        <enabled>true</enabled>                    </releases>                    <snapshots>                        <enabled>true</enabled>                    </snapshots>                </pluginRepository>            </pluginRepositories>        </profile>  </profiles>    <activeProfiles>        <activeProfile>dev</activeProfile>    </activeProfiles</settings>

上传中央仓库没有的Jar包到 Nexus
        
        使用 (拷贝到项目pom.xml使用)        
        效果        


参考        《Maven实战》-许晓斌(PDF链接:http://pan.baidu.com/s/1pJvCyuB 密码:6asf),主要参考第九章

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,028
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,518
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,366
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,146
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,780
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,858