Linux搭建Maven开发常用nexus私服

文章参考 :http://blog.csdn.net/cuker919/article/details/6338039 (Linux安装配置maven3.0以及搭建nexus私服

搭建之前,先看下nexus中的几个仓库:

1,Public Repositories:仓库组,将所有策略为Release的仓库聚合并通过一致的地址提供服务。

2,3rd party:一个策略为Release的宿主类型仓库,用来部署无法从公共仓库获得的第三方发布版本构件。

3,Apache Snapshots:策略为Snapshots的代理仓库,用来代理Apache Maven仓库的快照版本构件。

4,Central:该仓库代理Maven的中央仓库,策略为Release,只会下载和缓存中央仓库中的发布版本构件。

5,Central M1 shadow:maven1格式的虚拟类型仓库。

6,Codehaus Snapshots:代理Codehaus Maven仓库快照版本的代理仓库。

7,Release:策略为Release的宿主类型仓库,用来部署组织内部的发布版本构件。

8,Snapshots:策略为Snapshots的宿主类型仓库,用来部署组织内部的快照版本构件。

5,下载nexus官网地点 http://www.sonatype.org/nexus/archived/#step2top (我下载了最新的)

repo的镜像http://mirrors.ibiblio.org/maven2/

搭建nexus私服

1、解压nexus-oss-webapp-1.8.0-bundle.tar.gz文件到指定目录

1.  #cp nexus-oss-webapp-1.8.0-bundle.tar.gz /usr/local

2.  #tar -zvxf nexus-oss-webapp-1.8.0-bundle.tar.gz

3.  #ln –s nexus-oss-webapp-1.8.0 nexus

2、启动nexus

1.  #cd /usr/local/nexus/bin/jsw

2.

3.  选择自己机器的版本:

4.

5.  #cd linux-x86-64/

6.  #./nexus start

7.

8.  重启:

9.  #./nexus restart

10.   停止:

11.   #./nexus stop

3、运行nexus

在浏览器中输入:http://changethislocalhost:8081/nexus

就可以看到nexus 的主页,点击右上角Log in

默认用户名和密码是:admin/admin123

运行后会自动生成一个nexus工作目录sonatype-work,nexus下载的jar包会存放在

sonatype-work/nexus/storage中

4、配置

1) 点击左侧菜单Repositories

分别将右侧列表中

1.  Apache Snapshots

2.  Codehaus Snapshots

3.  Maven Central

三个repository 的configuration配置选项中的Download
Remote Index 配置改为True,并保存设置,

然后在列表中分别右键点击三个Repository,点击ReIndex

true是开启,false是关闭 由于中央仓库内容比较多,因此其索引文件比较大,需要查看下载是否完成了,我们可以单击界面左边导航栏中的 Scheduled Tasks 链接后,就可以看到系统调度的任务其状态为 runing,在说哦因下载完毕之后,该任务就会消失。

Scheduled Tasks 界面:

只有下载了,在search查询才会有东西,不然什么都搜索不到。

2)增加新的Repository,有一些比较常用jar包在nexus提供的repository中可能找不到,

一般比较常用的有

1.  JBOSS的两个:

2.  http://repository.jboss.org/maven2/

3.  http://repository.jboss.org/nexus/content/repositories/releases/

4.  SUN的:

5.  http://download.java.net/maven/2/

6.  K-INT的:

7.  http://developer.k-int.com/maven2/

8.

9.  因为找juel:juel-impl:2.2.1 这个jar包,所以我还添加了一个自己找的:

10.   http://repository.exoplatform.org/content/groups/public/

添加步骤:

点击Add->Proxy Repository->填写Repository ID, Repository Name, 以及Remote Storage Location 其他的默认即可。

3) 将新增的Repository添加到Public
Repositories中

在Public Repositories 的Configuration中,将多选Select中的项全部添加到左边,然后保存。

4) 添加自己的jar包

1.  在repository列表中有一个3rd party,也就是第三方jar包,点击会看到一个Artifact Upload选项卡,点击后,填写相应的信息。

2.  GAV Definition 一般选择 GAV Parameters

3.  然后添加Group:Artifact:Version:Package

4.  示例    juel:juel-impl:2.2.1:jar

然后选择要上传的jar包,保存即可

比如我们项目需要如下几个包:

javax.jms:jms:1.1:jar

proxool:proxool:0.9.1:jar

proxool:proxool-cglib:0.9.1:jar

com.lowagie:itextasian:1.0:jar

com.danga.MemCached:memcached:2.0.1:jar

5) nexus中设置代理服务器

选择左侧administrator菜单中的Server选项,在右侧打开的页面的中下部,有一个选择项:Default HTTP
Proxy Settings(optional) 将前面的复选框选中,填写相应的代理服务器信息即可。 web-proxy.cce.hp.com:8080

6) 编写自己的settings.xml,文件内容如下:

1.   <settings>

2.     <proxies>

3.       <proxy>

4.         <id>normal</id>

5.         <active>true</active>

6.         <protocol>http</protocol>

7.         <username>deployment</username>

8.         <password>deploy</password>

9.         <host>changethislocalhost:8081/nexus</host>

10.        <port>80</port>

11.        <nonProxyHosts>changethislocalhost:8081/nexus</nonProxyHosts>

12.      </proxy>

13.    </proxies>

14.

15.    <mirrors>

16.      <mirror>

17.        <!–This is used to direct the public snapshots repo in the

18.            profile below over to a different nexus group –>

19.        <id>nexus-public-snapshots</id>

20.        <mirrorOf>public-snapshots</mirrorOf>

21.        <url>http://changethislocalhost:8081/nexus/content/groups/public-snapshots</url>

22.      </mirror>

23.      <mirror>

24.        <!–This sends everything else to /public –>

25.        <id>nexus</id>

26.        <mirrorOf>*</mirrorOf>

27.        <url>http://changethislocalhost:8081/nexus/content/groups/public</url>

28.      </mirror>

29.    </mirrors>

30.

31.    <profiles>

32.      <profile>

33.        <id>nexus</id>

34.        <repositories>

35.          <repository>

36.            <id>central</id>

37.            <url>http://central</url>

38.            <releases><enabled>true</enabled></releases>

39.            <snapshots><enabled>true</enabled></snapshots>

40.          </repository>

41.        </repositories>

42.       <pluginRepositories>

43.          <pluginRepository>

44.            <id>central</id>

45.            <url>http://central</url>

46.            <releases><enabled>true</enabled></releases>

47.            <snapshots><enabled>true</enabled></snapshots>

48.          </pluginRepository>

49.        </pluginRepositories>

50.      </profile>

51.      <profile>

52.        <!–this profile will allow snapshots to be searched when activated–>

53.        <id>public-snapshots</id>

54.        <repositories>

55.          <repository>

56.            <id>public-snapshots</id>

57.            <url>http://public-snapshots</url>

58.            <releases><enabled>false</enabled></releases>

59.            <snapshots><enabled>true</enabled></snapshots>

60.          </repository>

61.        </repositories>

62.       <pluginRepositories>

63.          <pluginRepository>

64.            <id>public-snapshots</id>

65.            <url>http://public-snapshots</url>

66.            <releases><enabled>false</enabled></releases>

67.            <snapshots><enabled>true</enabled></snapshots>

68.          </pluginRepository>

69.        </pluginRepositories>

70.      </profile>

71.    </profiles>

72.    <activeProfiles>

73.      <activeProfile>nexus</activeProfile>

74.    </activeProfiles>

75.  </settings>

将settings.xml文件复制到${user}/.m2目录下

7) 测试

创建一个maven项目

#mvn archetype:generate

如果创建一个web项目可以选择83

填写相应的信息,maven会从私服上下载相应的jar包,看到的地址应该都是changethislocalhost的

项目创建成功后,将自己的pom.xml文件放在项目,执行

#mvn install 或者#mvn package

mvn会下载pom.xml文件定义的jar依赖

下载完成后,你可以在自己指定的repository目录下, 如果没有指定则是在 .m2/repository目录下查看自己的jar包

至此,我们的maven安装以及私服的搭建工作就完成了。

其中错误整理:

运行如下命令尝试快速构建一个maven项目:

mvn archetype:generate

出现了错误,解决的几种途径(我没有解决)

参考    http://www.cnblogs.com/chenying99/archive/2013/06/09/3127930.html (解决错误的三种方式)

在maven中配置setting等使用镜像mirror配置参考

<mirror>

<id>mirrors.ibiblio.org</id>

<name>mirrors.ibiblio.org</name>

<url>http://mirrors.ibiblio.org/maven2/</url>

<mirrorOf>central</mirrorOf>

</mirror>

<mirror>

<id>nexus-tmatesoft</id>

<mirrorOf>central</mirrorOf>

<name>Nexus tmatesoft</name>

<url>http://maven.tmatesoft.com/content/groups/public/</url>

</mirror>

或者

<mirror>

<id>uk.maven.org</id>

<mirrorOf>central</mirrorOf>

<name>UK Central</name>

<url>http://uk.maven.org/maven2</url>

</mirror>

<!-- United States, St. Louis-->

<mirror>

<id>Central</id>

<url>http://repo1.maven.org/maven2</url>

<mirrorOf>central</mirrorOf>

</mirror>

<!-- France -->

<mirror>

<id>antelink.com</id>

<url>http://maven.antelink.com/content/repositories/central/</url>

<mirrorOf>central</mirrorOf>

</mirror>

可以在  pom.xml中添加

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

参考了网址 http://blog.sina.com.cn/s/blog_67aaf444010154nc.html

maven学习九之pom.xml或settings.xml对nexus的配置(转)

时间: 2024-08-09 22:00:47

Linux搭建Maven开发常用nexus私服的相关文章

使用nexus搭建maven仓库(本地私服)

我们在使用maven的时候,对于项目所依赖的jar包,maven默认会在中央仓库下载jar包,到本地的磁盘目录(如果没有配置则是用户目录下/.m2/repository文件夹下).如果公司内部搭了一个maven私服的话,开发人员将仓库地址指向内网仓库地址,需要的jar包可直接在私服取,下载速度比远程要快,如果本地仓库没有则自动从远程下载并保存在本地.本文使用nexus搭建一个私服. 一.下载nexus 在浏览器中搜索 Sonatype Nexus 进入官网,找到下载 .下载之后解压压缩包如下:

Eclipse搭建maven开发环境

上一篇学习了maven开发环境的搭建,并且手动编写了一个maven工程,但是这样子效率很低下,今天带大家学习在eclipse下搭建maven开发环境. 常用的maven命令 mvn clean :运行清理操作,会将target文件夹中的数据删除 mvn clean compile:先运行清理操作,之后运行编译操作,会将代码编译到target文件夹中. mvn clean test: 运行清理和测试 mvn clean package : 运行清理和打包 mvn clean install : 运

linux搭建maven环境

linux搭建maven环境 maven基于java,使用的前提是安装配置好jdk. 下载并配置maven 下载 sudo apt-get install maven 配置 查看安装路径,并记录下来 whereis maven 添加环境变量 sudo vi /etc/profile添加:export M2_HOME=/usr/lib/mavenexport PATH=${M2_HOME}/bin:$PATH保存退出profile执行:source /etc/profile 更改mvn权限 sud

ava Maven项目之Nexus私服搭建和版本管理应用

目录: Nexus介绍 环境.软件准备 Nexus服务搭建 Java Maven项目版本管理应用 FAQ 1.Nexus介绍 Nexus是一个强大的Maven仓库管理器,它极大地简化了自己内部仓库的维护和外部仓库的访问.利用Nexus你可以只在一个地方就能够完全控制访问 和部署在你所维护仓库中的每个Artifact.我们可以在局域网搭建一个maven私服,用来部署第三方公共构件或者作为远程仓库在该局域网的一个代理. 2.环境.软件准备 本次演示环境,我是在本机mac上操作,以下是我本地软件及版本

Linux基本命令(开发常用的、电脑常用的)

一.开发常用的 ###转自:http://www.weixuehao.com/archives/25#usergroup 转自:http://blog.csdn.net/ljianhui/article/details/11100625 玩过Linux的人都会知道,Linux中的命令的确是非常多,但是玩过Linux的人也从来不会因为Linux的命令如此之多而烦恼,因为我们只需要掌握我们最常用的命令就可以了.当然你也可以在使用时去找一下man,他会帮你解决不少的问题.然而每个人玩Linux的目的都

Maven基础配置--nexus私服配置

登录nexus私服后台,按照下图1-3的顺序进行添加仓库: 其中步骤3有三种仓库类型(Type)进行选择 1. Hosted Repository:本地仓库,在私服服务器上存放用户自行上传的jar包: 2. Proxy Repository:远程代理仓库,从远程下载jar包,并保存在私服服务器: 3. Repository Group:可把上述仓库合并为一个组,方便使用: 两种jar包类型(Policy) 1. Release:稳定发布的版本: 2. Snapshot:不稳定的,正在开发中的版本

linux搭建C开发环境

目前决大多 数的Linux用户对Linux的了解还处于比较低级的层次,他们可能会几条命令.会配几种服务.会用rpm来安装软件.会操作KDE/Gnome界机等等,但是当他们遇到一些需要编译安装的软件时,面对一些简单的出错信息,他们就手足无措了.要想真正跨跃这些初级层次,你就不可能不去了解一些底层的东西,比如本文要讲到的Linux下的C开发环境以及本文之外的其它操作系统知识.  Linux和C天生有不解之源,大家可能知道Linux的操作系统内核就主要是用C写的,另外Linux下的很多软件也是用C写的

linux搭建maven私服

1.下载一个nexus3的镜像 docker pull sonatype/nexus3 2.将容器内部/var/nexus-data挂载到主机/root/nexus-data目录. docker run -d -p 8081:8081 --name nexus -v /root/nexus-data:/var/nexus-data --restart=always sonatype/nexus3 3.打开端口 iptables -A INPUT -ptcp --dport 8081 -j ACC

自己搭建maven开发环境的步骤及其注意事项

首先我们下载maven的安装包, 解压apache-maven-3.2.1-bin.zip到任意目录,在环境变量中进行设置 在命令行运行 mvn –version,出现以下提示表示安装成功. 在命令行里面运行 mvn help:system 此时会在你的用户目录下产生.m2文件夹和仓库文件 接下来我们从maven安装包里面复制settings.xml到adminministrator/.m2/下 我们对settings.xml做出如下改动 <?xml version="1.0"