本片是前一段时间搭Mvn + Neuxs环境, 在EverNote中做的笔记,今天把它腾到这里重新排版
前言
上周末终于把netmanage30项目迁移到了mvn环境下,其中各种折腾.现在终于熟悉了maven的使用方式.
按照best parctice需要使用nexus来做依赖管理服务器.在个人开发的方式下优势估计不是很明显,不过在团队开发中好处不言而喻.
说了这么多nexus到底有什么好处:
1. 统一管理依赖的jar包,作为一mvn的代理,所有链接到nexus上的用户公用一套nexus中的jar包.这样团队中之需要下载一次依赖
2. 团队中开发的bundle可以发布到nexus中进行共享.
3. mvn + nexus提供一种snapshot(快照)的版本发布方式.关于snapshot版本控制,下面这篇文章介绍的很详细:
http://juvenshun.iteye.com/blog/376422
在Ubuntu 10.04LTS 下安装Nexus
关于Nexus安装在哪里的问题,我毫不犹豫的选择Virtual Box虚拟机.好处就是研发环境如何变化,管理平台的环境始终保持不变.
ok~ 说了这么多废话,下面开始nexus安装, 在安装时我直接使用的root用户,如果选择其他用户需要使用sudo来提升权限, 如果不知道如何使用root用户的朋友可以使用如下指令:
#修改root密码,可以理解成激活root用户
passwd root
提示输入密码, 输入两遍即可.
注销当前用户,用root用户登录即可
1. 寻找最新版本的Nexus和文档
官方网站: http://nexus.sonatype.org/
官方文档: http://www.sonatype.com/books/nexus-book/reference/
2. 下载合适的Nexus
下载地址: http://nexus.sonatype.org/downloads/
Nexus分代jetty的独立版和war包形式的部署版,如果已经有随机启动的servlert contaner可以采用war形式,本次我打算采用独立版
独立版选择 *.tar.gz/*.zip 压缩包即可:
wget http://nexus.sonatype.org/downloads/nexus-oss-webapp-1.9.2-bundle.tar.gz
3. 安装Nexus
1). 解压缩
tar -zvxf nexus-oos-webapp-1.9.2-bundle.tar.gz
2). 将文件移动到对应路径,并将文件名重命名为nexus-1.9.2
mv ./nexus-oos-webapp-1.9.2-bundle.tar.gz /usr/local/nexus-1.9.2
3). 首次运行nexus:(注意: 在此之前需要确保配置好了java环境)
/usr/local/nexus-1.9.2/bin/jsw/linux-x86-32/nexus start
#监视一下日志
tail -f /usr/local/nexus-1.9.2/logs/wrapper.log
4). 访问如下地址访问Nexus:
http://localhost:8081/nexus
到此,如果不想做额外,nexus已可以使用.下面需要配置"环境变量"和"系统服务",好处就是可以方便使用.
4. 添加环境变量
1).编辑profile文件
gedit ~/.profile
2).加入如下内容:
export NEXUS_HOME=/usr/local/nexus-1.9.2
export PATH=$NEXUS_HOME/bin/jsw/linux-x86-32/:$PATH
3). 重新登录之后可以使其生效
试试 nexus console
5. 增加启动服务:
1). 将$NEXUS_HOME/bin/jsw/bin/linux-x86-32/nexus复制到/etc/init.d下
cp $NEXUS_HOME/bin/jsw/bin/linux-x86-32/nexus /etc/init.d
2). 编辑/etc/init.d/nexus
gedit /etc/init.d/nexus
修改如下内容:
# Application
APP_NAME="nexus"
APP_LONG_NAME="Sonatype Nexus"
NEXUS_HOME=/usr/local/nexus-1.9.2
PLATFORM=linux-x86-32
# Wrapper
WRAPPER_CMD=$NEXUS_HOME/bin/jsw/$PLATFORM/wrapper
WRAPPER_CONF=$NEXUS_HOME/bin/jsw/conf/wrapper.conf
# Location of the pid file.
PIDDIR="/var/run"
3). 添加成服务,并执行
cd /etc/init.d
update-rc.d nexus defaults
#执行
service nexus start
#Starting Sonatype Nexus...
tail -f /usr/local/nexus/logs/wrapper.log
让Maven链接上Nexus
1. 修改maven设置
一般我们修改用户设置, ~/.m2/settings.xml
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.0.107: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>
<!-- 设置发布时的用户名 -->
<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
</settings>
2. 在项目pom.xml设置发布目录:
<properties>
<nexus.url>192.168.0.107:8081</nexus.url>
</properties>
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://${nexus.url}/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://${nexus.url}/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
3. 估计已经迫不及待的尝试了
mvn install
Maven一般会先从本地读取jar文件,如果找不到再从远程服务器上读取, 如果之前在没有nexus下使用过mvn,可以先将本地仓库清空,之后在运行mvn install
- 大小: 40.9 KB
分享到:
相关推荐
持续集成环境maven+nexus+jenkins+svn搭建
详细介绍持续集成环境hudson+nexus+maven搭建
Nexus搭建Maven私服 +maven安装步骤
nexus+svn+jenkin_hudson+maven+禅道项目管理软件环境搭建二,继之前第二部分
nexus+svn+jenkin_hudson+maven+禅道项目管理软件环境搭建:基于敏捷开发流程及持续集成理念,通过工具,搭建软件开发和自动化测试的环境,提高开发效率,简化管理流程;此为部分一
nexus 搭建 maven仓库nexus 搭建 maven仓库nexus 搭建 maven仓库nexus 搭建 maven仓库nexus 搭建 maven仓库
该项目采用maven聚合工程,项目骨架是我们以前公司架构师搭建骨架,现在已经拆分出来供大家下载使用,可以扩展使用,里面用到技术有springmvc+mybatis+mysql+log4j.xml+logjdbc+maven+nexus+dubbo ,其中日志采用log...
linux,搭建maven私服,nexus3.14+maven3.6.3.zip,apache-maven-3.6.3-bin.tar.gz,nexus-3.14.0-04-unix.tar.gz
nexus 官网下载速度缓慢,所以将资源nexus上传上来共享一波。给需要搭建自己私服的朋友一个机会。。 。
包括: 1 Nexus 研究汇总(概念、作用、安装、管理操作) 2 Maven3 研究汇总(概念、作用、安装、核心流程、生命周期和阶段等核心、实用技术) 3用nexus搭建maven私服 4 eclipse+nexus+maven+JAVA Project管理实战
我们所需的所有构件都需要通过maven的中央仓库和第三方的Maven仓库下载到本地,而一个团队中的所有人都重复的从maven仓库下载构件无疑加大了仓库的负载和浪费了外网带宽,如果网速慢的话
个人整合网上资源加上自己的实践 成功的搭建了一套Git Nexus私服 Hudson管理的环境 并附有Checkout commit deploy 实例
Windows 下Nexus搭建Maven私服 Windows 下Nexus搭建Maven私服
nexus Maven
Maven Nexus 私服搭建 从零开始,资源下载、安装指导、开发配置说明
关于使用Nexus搭建Maven私服的开发文档。新手了解一下。
提供了基于Nexus搭建Maven私服所需要的一切资源和个人经验,搭建后可maven deploy 上传自己的jar包。别人如何在自己的maven项目中引用我将单独再上传一份。
nexus maven私服搭建nexus maven私服搭建nexus maven私服搭建nexus maven私服搭建nexus maven私服搭建nexus maven私服搭建
持续集成环境maven+nexus+jenkins+svn搭建[整理].pdf