linux maven 远程仓库,Linux下使用nexus搭建maven仓库私服

本文详述了如何在Linux环境中使用Nexus搭建Maven私服,包括下载安装、启动Nexus、配置Nexus以及如何在项目中使用和发布构件到远程仓库。通过Nexus,可以方便地管理jar包,避免直接依赖中央仓库。
摘要由CSDN通过智能技术生成

有个maven私服能够很方便地管理咱们的jar包和发布构建到远程仓库,本文就介绍了如何在linux下一步步使用nexus搭建maven私服java

原文连接:linux

下载安装

解压后会在同级目录中,出现两个文件夹:nexus-2.11.4-01和sonatype-work,前者包含了nexus的运行环境和应用程序,后者包含了你本身的配置和数据。网络

解压命令:unzip nexus-2.11.4-01-bundle.zipapp

启动nexus

# cd nexus-2.11.4-01/bin/

# ls

jsw  nexus  nexus.bat

# ./nexus

Usage: ./nexus { console | start | stop | restart | status | dump }

# ./nexus start

****************************************

WARNING - NOT RECOMMENDED TO RUN AS ROOT

****************************************

Starting Nexus OSS...

Started Nexus OSS.

查看控制台:less

# ./nexus console

****************************************

WARNING - NOT RECOMMENDED TO RUN AS ROOT

****************************************

Running Nexus OSS...

wrapper  | --> Wrapper Started as Console

wrapper  | Launching a JVM...

wrapper  | JVM exited while loading the application.

jvm 1    | wrapper  | Unable to start JVM: No such file or directory (2)

wrapper  | Reloading Wrapper configuration...

wrapper  | Launching a JVM...

wrapper  | JVM exited while loading the application.

jvm 2    | wrapper  | Unable to start JVM: No such file or directory (2)

wrapper  | Reloading Wrapper configuration...

wrapper  | Launching a JVM...

wrapper  | JVM exited while loading the application.

jvm 3    | wrapper  | Unable to start JVM: No such file or directory (2)

wrapper  | Reloading Wrapper configuration...

wrapper  | Launching a JVM...

wrapper  | JVM exited while loading the application.

jvm 4    | wrapper  | Unable to start JVM: No such file or directory (2)

wrapper  | Reloading Wrapper configuration...

wrapper  | Launching a JVM...

wrapper  | JVM exited while loading the application.

jvm 5    | wrapper  | Unable to start JVM: No such file or directory (2)

wrapper  | There were 5 failed launches in a row, each lasting less than 300 seconds.  Giving up.

wrapper  |   There may be a configuration problem: please check the logs.

wrapper  | 

启动失败,缘由:未安装JDK

eclipse

安装JDK后,查看控制台:jvm

# ./nexus console

****************************************

WARNING - NOT RECOMMENDED TO RUN AS ROOT

****************************************

Running Nexus OSS...

Nexus OSS is already running.

控制台显示启动成功。maven

查看nexus日志:

# cd ../logs/

# ls -l

total 48

-rw-r--r-- 1 root root 43311 2015-09-16 19:46 wrapper.log

# tail -f wrapper.log

配置nexus

7dd34435e41c46628b18b53b.html

右上角以admin登录,默认用户名/密码:admin/admin123。

7dd34435e41c46628b18b53b.html

3rd party、Snapshots、Releases这三个,分别用来保存第三方jar、项目组内部的快照、项目组内部的发布版.

手动添加第三方jar

将第三方的jar上传到nexus上面:

7dd34435e41c46628b18b53b.html

7dd34435e41c46628b18b53b.html

点击Upload Artifact(s)按钮提交后即上传。

查看上传的jar包以下:

7dd34435e41c46628b18b53b.html

在项目中使用私服的jar包配置pom.xml以下:

  4.0.0  com.vclk.mkt.crawler  MarketingCrawler  jar  0.3  MarketingCrawler  http://maven.apache.org                    nexus          Team Nexus Repository          http://yourhostname:8081/nexus/content/groups/public                              nexus          Team Nexus Repository          http://yourhostname:8081/nexus/content/groups/public                            de.innosystec          java-unrar          0.5        

Maven在项目根目录下执行mvn eclipse:eclipse命令时,所依赖的jar包都会从私服中下载到本地并关联上项目,私服中没有就会从网络上下载到私服,本地再从私服下载。

7dd34435e41c46628b18b53b.html

自动发布构件到远程仓库

在工程的pom.xml中添加:

        nexus-releases      http://yourhostname:8081/nexus/content/repositories/releases/          nexus-snapshots      http://yourhostname:8081/nexus/content/repositories/snapshots/  

进入maven的安装目录apache-maven-3.1.1\conf目录下,向settings.xml配置文件中的语句块中添加以下所示:

        nexus-releases      admin      admin123          nexus-snapshots      admin      admin123  

进入windows命令行,在工程所在目录下执行

mvn deploy

所部署的包就自动上传到了nexus安装目录下的 /maven/nexus/sonatype-work/nexus/storage/releases/com/vclk/mkt/crawler/MarketingCrawler/0.3 目录

nexus仓库中各目录介绍

项目中的各类jar包和项目快照等都放在 /nexus/sonatype-work/nexus/storage/ 目录下,在这个目录下包括如下各类目录和存放相应文件。

/nexus/sonatype-work/nexus/storage/central - 用于放置maven从中央仓库中下载下来的项目pom.xml中配置到的相关jar包;

/nexus/sonatype-work/nexus/storage/thirdparty - 用于放置本身手动上传的第三方jar包;

/nexus/sonatype-work/nexus/storage/releases - 用于放置项目deploy后的发布版。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值