[首页]
[文章]
[教程]
首页
Web开发
Windows开发
编程语言
数据库技术
移动平台
系统服务
微信
设计
布布扣
其他
数据分析
首页
>
系统服务
> 详细
Linux 安装配置maven3.0 以及搭建nexus私服
时间:
2015-05-14 16:43:49
阅读:
204
评论:
0
收藏:
0
[点我收藏+]
一、软件准备
1、apache-maven-3.0-bin.tar.gz 下载地址:
http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.0-bin.tar.gz
2、nexus-oss-webapp-1.8.0-bundle.tar.gz 下载地址:
http://nexus.sonatype.org/downloads/
二、maven安装配置
1、创建需要操作maven的用户组以及用户(如果用root用户安装不用创建)
Java代码
#groupadd configer
//创建用户组
#useradd -g configer configer
//创建用户并指定用户组
#passwd configer
//为用户分配密码
2、创建解压目录,并将apache-maven-3.0-bin.tar.gz文件解压到指定目录
Java代码
#cd /opt
#mkdir maven
#chown -R configer:configer /opt/maven
#chmod
755
/opt/maven
#su -l configer
#tar -zvxf apache-maven-
3.0
-bin.tar.gz
2、配置环境变量
Java代码
#vi /home/configer/.bash_profile
在文件中添加如下行:
Java代码
M2_HOME=/opt/maven/apache-maven-
3.0
export M2_HOME
PATH=$PATH:$M2_HOME/bin
export PATH
3、查看版本
Java代码
#cd /opt/maven/apache-maven-
3.0
/bin
#mvn --version
如果显示版本信息,应该会在${user}目录下创建.m2目录
4、查看.m2目录
Java代码
#cd /home/configer/.m2
如果没有.m2目录,则可以手动添加一个
#mkdir .m2
5、如果需要把maven的repository目录指定到其他目录,则修改maven安装目录下conf中的配置文件settings.xml文件
Java代码
#vi /opt/maven/apache-maven-
3.0
/conf/settings.xml
将文件中<localRepository>....</localRepository>的注释打开
或者在文件中增加 在这个注释下增加
<localRepository>your repository path</localRepository>
二、搭建nexus私服
1、解压nexus-oss-webapp-1.8.0-bundle.tar.gz文件到指定目录
Java代码
#tar -zvxf nexus-oss-webapp-
1.8
.
0
-bundle.tar.gz
2、启动nexus
Java代码
#cd /opt/maven/nexus-oss-webapp-
1.8
.
0
/bin/jsw
选择自己机器的版本:
#cd linux-x86-
32
/
#./nexus start
重启:
#./nexus restart
停止:
#./nexus stop
3、运行nexus
在浏览器中输入:http://localhost:8081/nexus
就可以看到nexus 的主页,点击右上角Log in
默认用户名和密码是:admin/admin123
运行后会自动生成一个nexus工作目录sonatype-work,nexus下载的jar包会存放在
sonatype-work/nexus/storage中
4、配置
1)点击左侧菜单Repositories
分别将右侧列表中
Java代码
Apache Snapshots
Codehaus Snapshots
Maven Central
三个repository 的Download Remote Index 配置改为True,并保存设置,
然后在列表中分别右键点击三个Repository,点击ReIndex
2)增加新的Repository,有一些比较常用jar包在nexus提供的repository中可能找不到,
一般比较常用的有
Java代码
JBOSS的两个:
http:
//repository.jboss.org/maven2/
http:
//repository.jboss.org/nexus/content/repositories/releases/
SUN的:
http:
//download.java.net/maven/2/
K-INT的:
http:
//developer.k-int.com/maven2/
因为找juel:juel-impl:
2.2
.
1
这个jar包,所以我还添加了一个自己找的:
http:
//repository.exoplatform.org/content/groups/public/
添加步骤:
Java代码
点击Add->Proxy Repository->填写Repository ID, Repository Name, 以及Remote Storage Location 其他的默认即可。
3) 将新增的Repository添加到Public Repositories中
在Public Repositories 的Configuration中,将多选Select中的项全部添加到左边,然后保存。
4) 添加自己的jar包
Java代码
在repository列表中有一个3rd party,也就是第三方jar包,点击会看到一个Artifact Upload选项卡,点击后,填写相应的信息。
GAV Definition 一般选择 GAV Parameters
然后添加Group:Artifact:Version:Package
示例 juel:juel-impl:
2.2
.
1
:jar
然后选择要上传的jar包,保存即可
5) nexus中设置代理服务器
选择左侧administrator菜单中的Server选项,在右侧打开的页面的中下部,有一个选择项:Default HTTP Proxy Settings(optional) 将复选框选中,填写相应的代理服务器信息即可。
6) 编写自己的settings.xml,文件内容如下:
Java代码
<settings>
<proxies>
<proxy>
<id>normal</id>
<active>
true
</active>
<protocol>http</protocol>
<username>deployment</username>
<password>deploy</password>
<host>localhost:
8081
/nexus</host>
<port>
80
</port>
<nonProxyHosts>localhost:
8081
/nexus</nonProxyHosts>
</proxy>
</proxies>
<mirrors>
<mirror>
<!--This is used to direct the
public
snapshots repo in the
profile below over to a different nexus group -->
<id>nexus-
public
-snapshots</id>
<mirrorOf>
public
-snapshots</mirrorOf>
<url>http:
//localhost:8081/nexus/content/groups/public-snapshots</url>
</mirror>
<mirror>
<!--This sends everything
else
to /
public
-->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http:
//localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>development</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>
<profile>
<!--
this
profile will allow snapshots to be searched when activated-->
<id>
public
-snapshots</id>
<repositories>
<repository>
<id>
public
-snapshots</id>
<url>http:
//public-snapshots</url>
<releases><enabled>
false
</enabled></releases>
<snapshots><enabled>
true
</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>
public
-snapshots</id>
<url>http:
//public-snapshots</url>
<releases><enabled>
false
</enabled></releases>
<snapshots><enabled>
true
</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>development</activeProfile>
</activeProfiles>
</settings>
将settings.xml文件复制到${user}/.m2目录下
7) 测试
创建一个maven项目
Java代码
#mvn archetype:generate
如果创建一个web项目可以选择83
填写相应的信息,maven会从私服上下载相应的jar包,看到的地址应该都是localhost的
项目创建成功后,将自己的pom.xml文件放在项目,执行
Java代码
#mvn install 或者#mvn
package
mvn会下载pom.xml文件定义的jar依赖
下载完成后,你可以在自己指定的repository目录下,如果没有指定则是在.m2/repository目录下查看自己的jar包
至此,我们的maven安装以及私服的搭建工作就完成了。
Linux 安装配置maven3.0 以及搭建nexus私服
原文:http://my.oschina.net/yygh/blog/414830
踩
(
0
)
赞
(
0
)
举报
评论
一句话评论(
0
)
登录后才能评论!
分享档案
更多>
2021年09月23日 (328)
2021年09月24日 (313)
2021年09月17日 (191)
2021年09月15日 (369)
2021年09月16日 (411)
2021年09月13日 (439)
2021年09月11日 (398)
2021年09月12日 (393)
2021年09月10日 (160)
2021年09月08日 (222)
最新文章
更多>
2021/09/28 scripts
2022-05-27
vue自定义全局指令v-emoji限制input输入表情和特殊字符
2022-05-27
9.26学习总结
2022-05-27
vim操作
2022-05-27
深入理解计算机基础 第三章
2022-05-27
C++ string 作为形参与引用传递(转)
2022-05-27
python 加解密
2022-05-27
JavaScript-对象数组里根据id获取name,对象可能有children属性
2022-05-27
SQL语句——保持现有内容在后面增加内容
2022-05-27
virsh命令文档
2022-05-27
教程昨日排行
更多>
1.
list.reverse()
2.
Django Admin 管理工具
3.
AppML 案例模型
4.
HTML 标签列表(功能排序)
5.
HTML 颜色名
6.
HTML 语言代码
7.
jQuery 事件
8.
jEasyUI 创建分割按钮
9.
jEasyUI 创建复杂布局
10.
jEasyUI 创建简单窗口
友情链接
汇智网
PHP教程
插件网
关于我们
-
联系我们
-
留言反馈
- 联系我们:wmxa8@hotmail.com
© 2014
bubuko.com
版权所有
打开技术之扣,分享程序人生!