您的位置:首页 > 其它

【Maven】Nexus(Maven仓库私服)下载与安装

2017-05-15 00:00 671 查看

Nexus介绍

  Nexus 是Maven仓库管理器,如果你使用Maven,你可以从Maven中央仓库 下载所需要的构件(artifact),但这通常不是一个好的做法,你应该在本地架设一个Maven仓库服务器,在代理远程仓库的同时维护本地仓库,以节省带宽和时间,Nexus就可以满足这样的需要。此外,他还提供了强大的仓库管理功能,构件搜索功能,它基于REST,友好的UI是一个extjs的REST客户端,它占用较少的内存,基于简单文件系统而非数据库。这些优点使其日趋成为最流行的Maven仓库管理器。

Nexus下载

 下载地址:http://www.sonatype.org/nexus/,下载开源版本

    NEXUS OSS [OSS = Open Source Software,开源软件——免费]
    NEXUS PROFESSIONAL -FREE TRIAL [专业版本——收费]。
    


      


Nexus安装

 安装环境:操作系统:Linxu(CentOS)

将压缩包解压到/usr目录下,nexus里面有2个文件夹,第一个文件夹是核心文件,第二个文件夹用来存储下载下来的jar:

    


    


 修改端口,进入nexus/nexubs-2.13.0-01/conf目录下,编辑nexus.properties文件,命令:vim nexus.properties

    


    


 启动nexus,进入nexus/nexubs-2.13.0-01/bin目录,

    


运行命令:./nexus //可以查看有那些运行命令

    


运行命令:./nexus start //启动nexus

    


    注意:可能会报错,报上面错误时:需要修改运行的用户,修改运行文件 nexus,命令:vim nexus,将RUN_AS_USER修改为root;
    


    


    保存之后,再次启动nexus,运行命令:./nexus start
    


 查看nexus 控制台,命令:./nexus console

    


 在浏览器进行访问。地址:http://ip:端口/nexus

    


 在网页上的右上角进行登录,默认用户名:admin,密码:admin123

    


    


3. 进入Nexus管理页面 http://localhost:8081/nexus/index.html 默认密码 admin admin123

点击Repositories ,可以看到仓库列表,包括下面几种:
Public Repositories 仓库组
3rd part 三方库,可以上传jar包到这个仓库
Central maven中心仓库
Releases 自己项目中发布的构建
Snapshots trunk 下开发一个项目

这里需要注意把Central 仓库的自动更新设置为True:

更新之后能看到Index:

4. 在settings.xml中使用本地仓库:
~/.m2 下新建settings.xml :



<profile>
<id>dev</id>
<repositories>
<repository>
<id>nexus</id>
<url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>

<pluginRepository>

<id>nexus</id>

<url>http://127.0.0.1:8081/nexus/content/groups/public</url>

<releases>

<enabled>true</enabled>

</releases>

<snapshots>

<enabled>true</enabled>

</snapshots>

</pluginRepository>

</pluginRepositories>

</profile>
</profiles>

<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>




方式二



<profile>
<id>dev</id>
<activation>
<jdk>1.7</jdk>
</activation>
<repositories>
<repository>
<id>devRepos</id>
<name>dev Repository</name>
<url>http://127.0.0.1:8081/nexus/content/repositories/devRepos/</url>
<layout>default</layout>
</repository>
</repositories>
</profile>




现在可以通过maven实验一下:
mvn archetype:create -DgroupId=com.yourcompany -DartifactId=myproject -DarchetypeArtifactId=maven-archetype-webapp

lvkun@lvkun-duitang:~/workspace$ mvn archetype:create -DgroupId=com.yourcompany -DartifactId=myproject -DarchetypeArtifactId=maven-archetype-webapp
[INFO] Scanning for projects...
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom (5 KB at 27.2 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom (13 KB at 409.6 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/maven-parent/16/maven-parent-16.pom Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/maven-parent/16/maven-parent-16.pom (23 KB at 463.8 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/apache/7/apache-7.pom Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/apache/7/apache-7.pom (15 KB at 563.7 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar (23 KB at 459.9 KB/sec)
http://blog.csdn.net/shenshen123jun/article/details/9084293#
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: