Maven私服搭建

来源:互联网 发布:淘宝手提包最低价 编辑:程序博客网 时间:2024/04/29 05:00
本文的maven私服搭建在 SuSE Linux上进行.环境: jdk1.7,Sonatype Nexus,MavenIP:192.168.1.132前提:已安装 JDK7 并配置好了环境变量1、下载最新版 Nexus(本教程使用的是:nexus-2.11.2-03-bundle.tar.gz),下载地址:http://www.sonatype.org/nexus/go/# wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.11.2-03-bundle.tar.gz2、解压# mkdir nexus# tar -zxvf nexus-2.11.2-03-bundle.tar.gz -C nexus# cd nexus# lsnexus-2.11.2-03 sonatype-work(一个 nexus 服务,一个私有库目录)3、编辑 Nexus 的 nexus.properties 文件,配置端口和 work 目录信息(保留默认)# cd nexus-2.11.2-03# cd conf# vi nexus.properties文件内容如下:# Sonatype Nexus# ==============# This is the most basic configuration of Nexus.# Jetty sectionapplication-port=8082application-host=0.0.0.0nexus-webapp=${bundleBasedir}/nexusnexus-webapp-context-path=/nexus# Nexus sectionnexus-work=${bundleBasedir}/../sonatype-work/nexusruntime=${bundleBasedir}/nexus/WEB-INF4、编辑 nexus 脚本, 配置 RUN_AS_USER 参数vi /home/javadev/nexus/nexus-2.11.2-03/bin/nexus

这里写图片描述

5、防火墙中打开 8082 端口

这里写图片描述
重启防火墙使配置生效
rcSuSEfirewall2 restart

6、启动 nexus/home/javadev/nexus/nexus-2.11.2-03/bin # ./nexus startWARNING - NOT RECOMMENDED TO RUN AS ROOT****************************************Starting Nexus OSS...Removed stale pid file: /home/javadev/nexus/nexus-2.11.2-03/bin/../bin/jsw/linux-x86-64/nexus.pidStarted Nexus OSS.7、浏览器中打开:http://192.168.1.132:8082/nexus/

这里写图片描述

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

这里写图片描述
这里写图片描述
到此,Nexus 已安装完成,接下来是 Nexus 的配置

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

这里写图片描述
给用户配置邮箱地址,方便忘记密码时找回:

这里写图片描述
用户修改密码
这里写图片描述
2、仓库类型
这里写图片描述

group  仓库组:Nexus 通过仓库组的概念统一管理多个仓库,这样我们在项目中直接请求仓库组即可请求到仓库组管理的多个仓库;hosted : 宿主仓库: 主要用于发布内部项目构件或第三方的项目构件 (如购买商业的构件)以及无法从公共仓库获取的构件(如 oracle 的 JDBC 驱动)proxy  代理仓库:代理公共的远程仓库;virtual  虚拟仓库:用于适配 Maven 1;一般用到的仓库种类是 hosted、proxyHosted  仓库常 用类 型 说明:releases 内部的模块中 release 模块的发布仓库snapshots 发布内部的 SNAPSHOT 模块的仓库3rd party 第三方依赖的仓库,这个数据通常是由内部人员自行下载之后发布上去如果构建的 n Maven  项目本地仓库没有对应的依赖包,那么就会去 s Nexus  私服去下载,如果 Nexus 私服也没有此依赖包, 就回去远程中央仓库下载依赖, 这些中央仓库就是 proxy 。Nexus  私服下载成功后再下载至本地Maven3、设置 proxy 代理仓库(Apache Snapshots/Central/Codehaus Snapshots)准许远程下载,如

这里写图片描述

4.本机eclipse 中maven项目的pom.xml文件中 加入如下代码:    <profiles>        <profile>           <id>myself</id>                <activation>                    <activeByDefault>false</activeByDefault>                    <jdk>1.7</jdk>                </activation>                <repositories>                    <!-- 私有库地址-->                    <repository>                        <id>nexus</id>                        <url>http://192.168.1.132:8082/nexus/content/groups/public/</url>                        <releases>                            <enabled>true</enabled>                        </releases>                        <snapshots>                            <enabled>true</enabled>                        </snapshots>                    </repository>                </repositories>                      <pluginRepositories>                    <!--插件库地址-->                    <pluginRepository>                        <id>nexus</id>                        <url>http://192.168.1.132:8082/nexus/content/groups/public/</url>                        <releases>                            <enabled>true</enabled>                        </releases>                        <snapshots>                            <enabled>true</enabled>                       </snapshots>                    </pluginRepository>                </pluginRepositories>            </profile>    </profiles>    <!--激活profile-->    <activeProfiles>        <activeProfile>myself</activeProfile>    </activeProfiles>
0 0
原创粉丝点击