Linux下使用nexus搭建maven私服
2016-03-01 23:11
363 查看
Linux下使用nexus搭建maven私服
MAR 17TH, 2015 5:26PM - | COMMENTS -
目录
下载安装
启动nexus
配置nexus
手动添加第三方jar
自动发布构件到远程仓库
nexus仓库中各目录介绍
有个maven私服可以很方便地管理我们的jar包和发布构建到远程仓库,本文就介绍了如何在linux下一步步使用nexus搭建maven私服。
原文链接:
http://tianweili.github.io/blog/2015/03/17/linux-nexus-maven-private-server/
下载安装
最新nexus下载地址:http://www.sonatype.org/nexus/go解压后会在同级目录中,出现两个文件夹:
nexus-oss-webapp-1.8.0和
sonatype-work,前者包含了nexus的运行环境和应用程序,后者包含了你自己的配置和数据。
$ mkdir nexus $ tar xzvf /home/jili/nexus-2.7.0-05-bundle.tar.gz $ ls nexus-2.7.0-05 sonatype-work |
启动nexus
$ cd bin/ $ ls jsw nexus nexus.bat $ ./nexus Usage: ./nexus { console | start | stop | restart | status | dump } $ ./nexus start Starting Nexus OSS... Started Nexus OSS. |
$ ./nexus console |
$ ./nexus consoleRunning Nexus OSS... |
nexus-2.4-bundle.tar.gz版本JDK6会支持.
Nexus所有版本下载地址:http://www.sonatype.org/nexus/archived
下载Nexus2.4重来
$ ls |
查看nexus日志:
$ cd nexus-2.4.0-09/logs $ ls wrapper.log $ tail -f wrapper.log |
配置nexus
访问网址:http://yourhostname:8081/nexus![](http://7u2i08.com1.z0.glb.clouddn.com/java/nexus-maven-1.png)
右上角以admin登陆,默认用户名/密码:admin/admin123。
![](http://7u2i08.com1.z0.glb.clouddn.com/java/nexus-maven-2.png)
3rd party、Snapshots、Releases这三个,分别用来保存第三方jar、项目组内部的快照、项目组内部的发布版.
手动添加第三方jar
将第三方的jar上传到nexus上面:![](http://7u2i08.com1.z0.glb.clouddn.com/java/nexus-maven-3.png)
![](http://7u2i08.com1.z0.glb.clouddn.com/java/nexus-maven-4.png)
点击Upload Artifact(s)按钮提交后即上传。
查看上传的jar包如下:
![](http://7u2i08.com1.z0.glb.clouddn.com/java/nexus-maven-5.png)
在项目中使用私服的jar包配置pom.xml如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.vclk.mkt.crawler</groupId> <artifactId>MarketingCrawler</artifactId> <packaging>jar</packaging> <version>0.3</version> <name>MarketingCrawler</name> <url>http://maven.apache.org</url> <!-- 仓库地址 --> <repositories> <repository> <id>nexus</id> <name>Team Nexus Repository</name> <url>http://yourhostname:8081/nexus/content/groups/public</url> </repository> </repositories> <!-- 插件地址 --> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>Team Nexus Repository</name> <url>http://yourhostname:8081/nexus/content/groups/public</url> </pluginRepository> </pluginRepositories> <!-- jar --> <dependencies> <dependency> <groupId>de.innosystec</groupId> <artifactId>java-unrar</artifactId> <version>0.5</version> </dependency> </dependencies> </project> |
![](http://7u2i08.com1.z0.glb.clouddn.com/java/nexus-maven-6.png)
自动发布构件到远程仓库
在工程的pom.xml中添加:<distributionManagement> <repository> <id>nexus-releases</id> <url>http://yourhostname:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <url>http://yourhostname:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> |
<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> |
mvn deploy |
/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后的发布版。
相关文章推荐
- 在CentOS上安装ZooKeeper集群
- 学习linux决心书
- 学习linux决心书
- 我的决心书Linux
- Android(Linux)实时监测串口数据
- 关于Linux的历史
- linux基础概念与linux发展史
- 学习Linux决心书
- linux命令 vim
- Linux技术——netstat命令详解
- Linux System Programming读书笔记之deamon进程
- centos 6.5 samba简单配置
- linux命令详解
- linux ftrace原理
- centos6.5 php5.4 with-fpm 找不到php.ini Loaded Configuration File => (none)
- Linux学习笔记:简单了解与设置文件的权限
- Linux学习笔记(8)----基础正则表达式
- Linux学习笔记:简单了解用户,对用户的简单操作
- Linux内核设计第二周学习总结 完成一个简单的时间片轮转多道程序内核代码
- <深入理解Linux内核>--Linux源码步步为营 Unix内核概述