linux上安装maven私有库nexus私服

Maven私有库和本地库的安装与配置

SonatypeNexus + Maven

环境:CentOS6.6FinalJDK7Sonatype NexusMaven

IP:192.168.4.221

root用户操作

前提:已安装JDK7并配置好了环境变量

1、下载最新版Nexus(本教程使用的是:nexus-2.11.2-03-bundle.tar.gz,下载地址:http://www.sonatype.org/nexus/Go/

#wgethttps://sonatype-download.global.ssl.fastly.NET/nexus/oss/nexus-2.11.2-03-bundle.tar.gz

2、解压

# mkdirnexus

# tar -zxvfnexus-2.11.2-03-bundle.tar.gz -C nexus

# cd nexus

# ls

nexus-2.11.2-03 sonatype-work

(一个nexus服务,一个私有库目录)

3、编辑Nexusnexus.properties文件,配置端口和work目录信息(保留默认)

# cdnexus-2.11.2-03

# ls

bin conf lib  LICENSE.txt  logs nexus NOTICE.txt  tmp

查看目录结构,jetty运行

# cd conf

# vinexus.properties

# Jettysection

application-port=8081

application-host=0.0.0.0

nexus-webapp=${bundleBasedir}/nexus

nexus-webapp-context-path=/nexus

# Nexussection

nexus-work=${bundleBasedir}/../sonatype-work/nexus

runtime=${bundleBasedir}/nexus/WEB-INF

4、编辑nexus脚本,配置RUN_AS_USER参数

# vi /root/nexus/nexus-2.11.2-03/bin/nexus

#RUN_AS_USER=

改为:

RUN_AS_USER=root

5、防火墙中打开8081端口

# vi/etc/sysconfig/iptables

添加:

-A INPUT -mstate --state NEW -m tcp -p tcp --dport 8081 -jACCEPT

保存后重启防火墙

# serviceiptables restart

6、启动nexus

#/root/nexus/nexus-2.11.2-03/bin/nexus start

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

WARNING -NOTRECOMMENDED TO RUN AS ROOT

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

StartingNexus OSS...

StartedNexus OSS.

7、浏览器中打开:http://192.168.4.221:8081/nexus/


8、登录,默认用户名admin,默认密码admin123:

到此,Nexus已安装完成,接下来是Nexus的配置

Nexus配置(登录后)

1、菜单Administration/Server配置邮箱服务地址(如果忘记密码,可以通过该邮箱找回密码)

给用户配置邮箱地址,方便忘记密码时找回:

用户修改密码

1、仓库类型

group仓库组:Nexus通过仓库组的概念统一管理多个仓库,这样我们在项目中直接请求仓库组即可请求到仓库组管理的多个仓库;

hosted宿主仓库:主要用于发布内部项目构件或第三方的项目构件(如购买商业的构件)以及无法从公共仓库获取的构件(如OracleJDBC驱动)

proxy代理仓库:代理公共的远程仓库;

virtual虚拟仓库:用于适配Maven1

一般用到的仓库种类是hostedproxy

Hosted仓库常用类型说明:

releases内部的模块中release模块的发布仓库

snapshots发布内部的SNAPSHOT模块的仓库

3rd party第三方依赖的仓库,这个数据通常是由内部人员自行下载之后发布上去

如果构建的Maven项目本地仓库没有对应的依赖包,那么就会去Nexus私服去下载,

如果Nexus私服也没有此依赖包,就回去远程中央仓库下载依赖,这些中央仓库就是proxyNexus私服下载成功后再下载至本地Maven库供项目引用。

1、设置proxy代理仓库(Apache Snapshots/Central/CodehausSnapshots)准许远程下载,如:

4Maven本地库的安装与配置

环境变量、setting.xml

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.   
  3. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"   
  4.           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  5.           xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">  
  6.     <localRepository>E:/apache-maven-3.1.0/.m2/repository</localRepository>  
  7.     <interactiveMode>true</interactiveMode>  
  8.     <offline>false</offline>  
  9.     <pluginGroups>  
  10.         <pluginGroup>org.mortbay.jetty</pluginGroup>  
  11.         <pluginGroup>org.jenkins-ci.tools</pluginGroup>  
  12.     </pluginGroups>  
  13.       
  14.     <!--配置权限,使用默认用户-->  
  15.     <servers>  
  16.         <server>  
  17.             <id>nexus-releases</id>  
  18.             <username>deployment</username>  
  19.             <password>deployment123</password>  
  20.         </server>  
  21.         <server>   
  22.             <id>nexus-snapshots</id>  
  23.             <username>deployment</username>  
  24.             <password>deployment123</password>  
  25.         </server>  
  26.     </servers>  
  27.   
  28.     <mirrors>  
  29.   
  30.     </mirrors>  
  31.   
  32.     <profiles>  
  33.         <profile>  
  34.            <id>edu</id>  
  35.                 <activation>  
  36.                     <activeByDefault>false</activeByDefault>  
  37.                     <jdk>1.6</jdk>  
  38.                 </activation>  
  39.                 <repositories>  
  40.                     <!-- 私有库地址-->  
  41.                     <repository>  
  42.                         <id>nexus</id>  
  43.                         <url>http://192.168.4.221:8081/nexus/content/groups/public/</url>  
  44.                         <releases>  
  45.                             <enabled>true</enabled>  
  46.                         </releases>  
  47.                         <snapshots>  
  48.                             <enabled>true</enabled>  
  49.                         </snapshots>  
  50.                     </repository>  
  51.                 </repositories>        
  52.                 <pluginRepositories>  
  53.                     <!--插件库地址-->  
  54.                     <pluginRepository>  
  55.                         <id>nexus</id>  
  56.                         <url>http://192.168.4.221:8081/nexus/content/groups/public/</url>  
  57.                         <releases>  
  58.                             <enabled>true</enabled>  
  59.                         </releases>  
  60.                         <snapshots>  
  61.                             <enabled>true</enabled>  
  62.                        </snapshots>  
  63.                     </pluginRepository>  
  64.                 </pluginRepositories>  
  65.             </profile>  
  66.     </profiles>  
  67.       
  68.     <!--激活profile-->  
  69.     <activeProfiles>  
  70.         <activeProfile>edu</activeProfile>  
  71.     </activeProfiles>  
  72.       
  73. </settings>  

5MyEclipse中的Maven配置


6、项目的构建与发布演示

修改pom.xml中的私有库地址

7、上传第三方包操作演示

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值