首页 技术 正文
技术 2022年11月11日
0 收藏 919 点赞 2,956 浏览 2342 个字

  最近从SVN下载的代码,在本地构建时出现了诸多问题,部分依赖下载超时,就想起在局域网搭建Maven私服,废话不说了,在测试服务器上建的已经成功,就随便找台机子再练习一遍顺道写个日志。
1、前往http://www.sonatype.com/download-oss-sonatype下载Nexus-Bundle
  下载地址:http://www.sonatype.org/downloads/nexus-latest-bundle.zip
2、解压下载的nexus-2.13.0-01-bundle
  搭建Maven私服
3、安装并nexus服务
  更改nexus服务端口(可选步骤)
  搭建Maven私服
  这里使用默认端口 8081
  搭建Maven私服
5、修改用户Maven配置文件,%userprofile%\.m2\setting.xml
  搭建Maven私服
  Content of setting.xml (You should replace `username`,`password` & `url` in the file if you have changed them.)  

<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">
<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>adminsa</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>adminsa</password>
</server>
</servers> <mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.1.222:7758/nexus/content/groups/public/</url>
</mirror>
</mirrors> <profiles>
<profile>
<id>nexus</id>
<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>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>

6、客户端配置(假定已经配置好Maven运行环境)

  为pom.xml添加Maven私服配置
  搭建Maven私服
  Content of add item

<repositories>
<repository>
<id>nexus</id>
<name>Team Nexus Repository</name>
<url>http://127.0.0.1:8081/nexus/content/groups/public</url>
</repository>
</repositories><pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Team Nexus Repository</name>
<url>http://127.0.0.1:8081/nexus/content/groups/public</url>
</pluginRepository>
</pluginRepositories>

7、客户端测试(需要有Maven项目,没有点击下载 A Simple Maven Project
  进入到Maven项目目录(pom.xml所在目录)
  搭建Maven私服
8、验证Maven私服(Repositories -> Repository Path[Central])
  搭建Maven私服
9、看到刚刚使用 mvn clean命令下载的plexus-utils-3.0已经在私服仓库中,这时如果局域网内其他机器测试就会直接从私服上下载,为项目构建节省资源。
  可以看到在另一台机器上已经下载一上午的结果(Mac系统有时候让人很无语)
  搭建Maven私服
  再看看修改了pom.xml后再看看构建是个什么样子吧
  搭建Maven私服
  构建完成,是不是感觉用起来很爽,值得一提的是,其他客户机上同样需要在用户目录的.m2子目录中创建setting.xml配置上Maven私服。在Intellij Idea上直接 update indecies还不行,明明已经配置了使用下载的Maven,原因正在调查中。
  

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